The cblite Tool

February 20, 2025 · View on GitHub

cblite is a command-line tool for inspecting and querying LiteCore and Couchbase Lite databases (which are directories with a .cblite2 extension.)

For build instructions, see BUILDING.md. For convenience, binaries are available in the Releases tab.

NOTE: The source code for the tools is Apache-licensed, as specified in LICENSE. However, the pre-built cblite binaries are linked with the Enterprise Edition of Couchbase Lite, so the usage of those pre-built binaries will be guided by the terms and conditions specified in Couchbase's Enterprise License.

Official support of the cblite tool is not yet available. This applies also to the pre-built binaries that are linked with the Enterprise Edition of Couchbase.

Features

A selection of the available subcommands:

SubcommandPurpose
catDisplay the body of one or more documents
checkCheck for database corruption
compactCompact the database or prune old revisions
encrypt, decryptAdd or remove encryption (EE only)
import, exportImport or export a database to/from JSON
infoDisplay information about the database
lsList the documents in a collection
mkcollCreate a collection
mkindexCreate an index
mvMove a document between collections
push, pullSync with a remote database
putCreate or update a document
query, selectRun N1QL queries
revsList the revisions of a document
rmDelete documents
rmindexDrop an index

See the full documentation...

Example

$  cblite file travel-sample.cblite2
Database:   travel-sample.cblite2/
Total size: 34MB
Documents:  31591, last sequence 31591

$  cblite ls -l --limit 10 travel-sample.cblite2
Document ID     Rev ID     Flags   Seq     Size
airline_10      1-d70614ae ---       1     0.1K
airline_10123   1-091f80f6 ---       2     0.1K
airline_10226   1-928c43f4 ---       3     0.1K
airline_10642   1-5cb6252c ---       4     0.1K
airline_10748   1-630b0443 ---       5     0.1K
airline_10765   1-e7999661 ---       6     0.1K
airline_109     1-bd546abb ---       7     0.1K
airline_112     1-ca955c69 ---       8     0.1K
airline_1191    1-28dbba6e ---       9     0.1K
airline_1203    1-045b6947 ---      10     0.1K
(Stopping after 10 docs)

$  cblite travel-sample.cblite2
(cblite) query --limit 10 ["=", [".type"], "airline"]
["_id": "airline_10"]
["_id": "airline_10123"]
["_id": "airline_10226"]
["_id": "airline_10642"]
["_id": "airline_10748"]
["_id": "airline_10765"]
["_id": "airline_109"]
["_id": "airline_112"]
["_id": "airline_1191"]
["_id": "airline_1203"]
(Limit was 10 rows)
(cblite) query --limit 10 {WHAT: [[".name"]], WHERE:  ["=", [".type"], "airline"], ORDER_BY: [[".name"]]}
["40-Mile Air"]
["AD Aviation"]
["ATA Airlines"]
["Access Air"]
["Aigle Azur"]
["Air Austral"]
["Air Caledonie International"]
["Air Caraïbes"]
["Air Cargo Carriers"]
["Air Cudlua"]
(Limit was 10 rows)
(cblite) ^D
$