<p>Pretty sure the binary format is <a href="https://cbor.io/" rel="nofollow noreferrer">CBOR</a> and yes, the ledger state is <strong>HUGE</strong>.</p>
<p>I think that if you drop the <code>--out-file</code> command line option the output goes to stdout in JSON format but again the output on <code>mainnet</code> is so huge that for me <code>cardano-cli</code> is killed by the OOM killer on a machine with 16G of RAM.</p>
<p>Using the command you use, the output file is 1.4 Gigabytes (much more compact than the in-memory representation).</p>
<p>There is already a <a href="https://github.com/input-output-hk/cardano-node/issues/2461" rel="nofollow noreferrer">Github issue</a> about that which is almost a year old.</p>

CC BY-SA 4.0
2022-02-16T21:47:43.780Z
Thanks for the relevant information.
shawnim
CC BY-SA 4.0
2022-02-13T05:44:31.687Z
2022-02-13T06:39:05.613Z
2022-02-13T06:39:05.613Z
Erik de Castro Lopo
<p>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.</p>

CC BY-SA 4.0
2022-02-16T21:49:33.317Z
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
CC BY-SA 4.0
2022-02-13T15:06:06.277Z
2022-02-13T15:06:06.277Z
Matt Ho
<p>Running <code>cardano-cli query ledger-state --mainnet --out-file out</code> produces a binary file.
What format is it in?
How can I decode it?
I cannot use the command without <code>--out-file out</code> because of memory limitations.</p>
<p>UPDATE</p>
<p>I tried:</p>
<pre><code>pip install cbor2
cat ledger-state.cbor | python -m cbor2.tool --pretty &gt; ledger-state.json
</code></pre>
<p>which gave me:</p>
<pre><code>[
    320,
    {
        &quot;\u0000\u0000\u00006\\xd5\u0015\\xe1.\u0018\\xcd&lt;\\x88\\xc7O\t\\xa6y\\x84\\xc2\\xc2y\\xa5)j\\xa9n\\xfe\\x89&quot;: 58,
        &quot;\u0000\u0000\u0000\\xf6n(\\xb0\\xf1\\x8a\\xef U_LIT#N2p߻\\xdc\\xc1?T\\xe7\\x99&quot;: 57,
[...]
    }
]
</code></pre>
<p>which does not seem to be decoded properly.</p>

<cardano-cli>
How to decode output of cardano-cli query ledger-state?
# How to decode output of cardano-cli query ledger-state?

(Asked by: username_0 on 2022-02-13)

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.
UPDATE
I tried:
pip install cbor2
cat ledger-state.cbor | python -m cbor2.tool --pretty > ledger-state.json

which gave me:
[
    320,
    {
        "\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.

**Tags:** cardano-cli

---

## 2 answers

### Answer by username_1 on 2022-02-13. Score: 1

Pretty sure the binary format is [CBOR](https://cbor.io/) 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](https://github.com/input-output-hk/cardano-node/issues/2461) about that which is almost a year old.

> **Comments:**
> **username_0**: Thanks for the relevant information.  

---

### Answer by username_2 on 2022-02-13. Score: 1

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.

> **Comments:**
> **username_0**: 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.  

---

