Running cardano-cli query ledger-state --mainnet --out-file out produces a binary file. What format is it in? How can I decode it? I cannot use the command without --out-file out because of memory limitations.


I tried:

pip install cbor2
cat ledger-state.cbor | python -m cbor2.tool --pretty > ledger-state.json

which gave me:

        "\u0000\u0000\u00006\\xd5\u0015\\xe1.\u0018\\xcd<\\x88\\xc7O\t\\xa6y\\x84\\xc2\\xc2y\\xa5)j\\xa9n\\xfe\\x89": 58,
        "\u0000\u0000\u0000\\xf6n(\\xb0\\xf1\\x8a\\xef U_LIT#N2p߻\\xdc\\xc1?T\\xe7\\x99": 57,

which does not seem to be decoded properly.

2 Answers 2


Pretty sure the binary format is CBOR and yes, the ledger state is HUGE.

I think that if you drop the --out-file command line option the output goes to stdout in JSON format but again the output on mainnet is so huge that for me cardano-cli is killed by the OOM killer on a machine with 16G of RAM.

Using the command you use, the output file is 1.4 Gigabytes (much more compact than the in-memory representation).

There is already a Github issue about that which is almost a year old.

  • Thanks for the relevant information.
    – shawnim
    Commented Feb 16, 2022 at 21:47

If you're looking to create a readable snapshot of the Cardano ledger as of a given slot, might I suggest using ogmios.dev as a simpler solution. Ogmios allows one to read the entire state of the ledger via the chain sync mini-protocol. The ledger is exposed as a websocket api, reducing integration complexity.

  • I am planning on using Ogmios but was hoping for a quick and easy way to do a few inspections of the ledger from the commandline with jq.
    – shawnim
    Commented Feb 16, 2022 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.