How to Decode a Raw Bitcoin Transaction (With and Without a Node)
How to decode a raw Bitcoin transaction: read the version, inputs, outputs, scripts and locktime from a hex string. What decoderawtransaction returns, what raw hex cannot tell you, and how to decode by txid over an API instead of running a node.
By the BitcoinDatabase team
July 2026 · 8 min read
The short answer
To decode a raw Bitcoin transaction, you parse its hex string into structured fields: the version, the list of inputs (each with a previous txid, output index and unlocking script or witness), the list of outputs (each with a value in satoshis and a locking script that resolves to an address), and the locktime. Bitcoin Core does this with the decoderawtransaction command if you run a node. Without a node, you send the hex to a decoding API and get the same JSON back, and decoding by txid instead resolves the input addresses and amounts that raw hex alone cannot show.
A raw Bitcoin transaction is just a hex string: compact, exact, and unreadable at a glance. Decoding it turns that string into the fields you can reason about, which is what you need when you are debugging a wallet, auditing a payment, or building anything that touches transactions.
What is a raw Bitcoin transaction?
A raw Bitcoin transaction is the serialized, byte-level form of a transaction, usually shown as a hexadecimal string. It is the exact data that gets signed, broadcast and stored in a block, with no formatting and no labels, just fields packed one after another in a defined order. Every wallet builds one of these before broadcasting, and every node parses one when it receives it. Because it is canonical, the raw form is what you hash to get the transaction id and what you inspect when you need the ground truth about a transaction rather than a wallet's friendly summary.
What does a decoded transaction contain?
A decoded transaction contains four top-level parts, and reading them in order is most of the job.
| Field | What it tells you |
|---|---|
| version | The transaction format version, usually 1 or 2 |
| inputs (vin) | Each spends a prior output: previous txid, output index (vout), unlocking script and witness |
| outputs (vout) | Each pays a value in satoshis to a locking script that resolves to an address |
| locktime | The earliest block or time the transaction may be mined |
The outputs are where the money goes: each has an amount and a scriptPubKey that, once parsed, gives you the recipient address and the script type, whether legacy, SegWit or Taproot. The inputs point back to the outputs being spent, but note what they do not carry: the amount and address of what is being spent live in those prior transactions, not in this one.
How do you decode a raw transaction with Bitcoin Core?
You decode a raw transaction with Bitcoin Core by passing the hex to the decoderawtransaction remote procedure call, for example decoderawtransaction <hex>, which returns the parsed JSON with version, vin, vout and locktime. It is a purely local, offline operation: the node does not need the transaction to be confirmed or even valid to decode its structure. The catch is that you must be running a fully synced node to have the command available, which means hundreds of gigabytes of chain data and the operational burden of keeping it online. For an occasional decode, standing up a node is a lot of overhead. Our guide on accessing a Bitcoin node without running one covers the trade-off in depth.
What can a raw hex decode not tell you?
A raw hex decode cannot tell you the addresses and amounts of the inputs, because that information is not in the transaction you are decoding. Each input only references a previous transaction id and an output index. To learn that input number two was 0.4 BTC from a specific address, you have to fetch that prior transaction and read the referenced output. This is why a bare decoderawtransaction shows outputs fully but leaves inputs as pointers. Answering "who sent this and how much" requires the chain around the transaction, not just the transaction itself. That gap is exactly why turning raw, unstructured data into something clean and queryable is a recurring engineering problem well beyond Bitcoin, and it is often easier to let a service that has already structured the raw data hand you the resolved result.
How do you decode a transaction without a node?
You decode a transaction without a node by sending the raw hex to a decoding endpoint that returns the same structured JSON a node would, or better, by decoding it by its transaction id against an indexed chain. Decoding by txid is the more useful path for confirmed transactions: because the service already has every prior transaction indexed, it can resolve each input back to its address and amount and hand you a complete picture, inputs and outputs both, in one call. That is the difference between reading a transaction's structure and understanding what actually moved. A Bitcoin transaction decoder built on the indexed chain does exactly this, and the broader transaction API returns the same detail for any hash you look up.
When would you decode a raw transaction?
You would decode a raw transaction whenever you need to verify or understand a transaction before or after it is broadcast. Common cases include checking that a wallet built the outputs you expected before you sign and send, debugging why a transaction was rejected, auditing a payment for reconciliation or compliance, and teaching or researching how the protocol serializes data. In each case, the decode turns an opaque string into the specific facts you need: how much, to whom, from where, and under what conditions. If you are comparing ways to fetch that data programmatically, our write-up on Bitcoin RPC versus REST lays out when each fits.
Can I batch-decode many transactions?
Yes, you can batch-decode many transactions, and doing it against an indexed data service is far more practical than looping decoderawtransaction on a node. Because the chain is already parsed, you can request decoded transactions by txid in volume, or run SQL over the indexed inputs and outputs to pull exactly the fields you need across thousands of transactions at once. That is the right approach for reconciliation, forensic review or analytics, where decoding one transaction at a time would be slow and stitching in the prior outputs by hand would be error-prone.
Decoding a raw transaction is reading Bitcoin in its native form. The structure is always the same four parts, but the real answers, who paid what to whom, only appear once you resolve the inputs against the rest of the chain. Decode by txid on indexed data and you get the whole story in one call.
Hit Run to query the fully-indexed Bitcoin blockchain.
BTC
30-day trend
informational on-chain data · not financial advice
Query the Bitcoin blockchain yourself
Pull balances, UTXOs, transactions, on-chain metrics and fund flows from the fully indexed Bitcoin blockchain by REST API, SQL and dashboards. Indexed since 2009, new blocks within seconds, no node to run.