Export a DocumentDB collection to JSON
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Command-line utility to export a DocumentDB database/collection to a list of JSON documents.


The documentdbexport package is installed via npm:

npm install -g documentdbexport

You may need to precede the above command with sudo, depending on your Node.js installation.


The documentdbexport is configured by setting your Azure Endpoint and URL asas environment variables:

export AZURE_ENDPOINT="https://mydocumentdb.documents.azure.com:443/"
export AZURE_KEY="GeIZysnonvgpk2"

Command-line Usage

Use the documentdbexport tool to export an entire DocumentDB collection. The database is specified with -d and the collection with -c:

$ documentdbexport -d iot -c temperaturereadings
Export complete { records: 3, time: 0.145 }

The data can be directed to a text file:

$ documentdbexport -d iot -c temperaturereadings > mydata.txt
Export complete { records: 3, time: 0.145 }

or piped elsewhere e.g. to couchimport to import the data into Apache CouchDB:

$ documentdbexport -d iot -c temperaturereadings | couchimport --db mycouchtable --type jsonl
Export complete { records: 3, time: 0.145 }
couchimport writecomplete { total: 3, totalfailed: 0 } +20ms
couchimport Import complete

Programmatic Usage

You can also use the library within your own code:

var documentdbexport = require('documentdbexport');
var endpoint = 'https://mydocumentdb.documents.azure.com:443/';
var key = 'GeIZysnonvgpk2';
var database = 'mydatabase';
var collection = 'mycollection';
documentdbexport.exportCollection(endpoint, key, database, collection, function(err, data) {
  if (err) {
    console.error('ERROR', err)
  } else {
    console.error('Export complete', data)

Options Reference

Command-line parameters

  • -d or --database - the database to work with (required)
  • -c or --collection - the collection to export (required)

Environment variables

  • AZURE_ENDPOINT - the Azure endpoint URL key
  • AZURE_KEY - the Azure primary API key