# TON Decompiler (https://docs-kyrm16yq7-ton-core-docs.vercel.app/llms/tvm/tools/ton-decompiler/content.md)



[TON Decompiler](https://github.com/tact-lang/ton-opcode) is an utility for converting [BoC](/llms/foundations/serialization/boc/content.md) of the contract into a [Fift](/llms/languages/fift/overview/content.md)-like pseudocode.

Decompiled code cannot match match the original source. At the very least, variable names and high-level structure is removed during compilation. Variables and methods will get some generated names, for example, `?fun_ref_12345678`.

The resulting pseudocode might not compile back to the same BoC either.

## CLI usage [#cli-usage]

Install Tact language tool suite.

```bash
npm install -g @tact-lang/compiler
```

Then run it on a BoC file:

```bash
unboc example.boc
```

## API usage [#api-usage]

Add it to the project

```bash
npm install @tact-lang/ton-decompiler
```

Then call a disassembler to decompile it, and a writer to put the result back into Fift-like pseudocode.

```ts
import { Cell } from "@ton/core";
import { disassembleRoot } from "./decompiler/disasm";
import { AssemblyWriter } from "./printer/assembly-writer";

const cell: Cell = ...; // your TVM contract bytecode
const program = disassembleRoot(cell);
const writer = new AssemblyWriter();
const code = writer.write(program);
console.log(code);
```
