# translate a document between data formats

dmog translates a document from any of 22 data formats into any other as it reads, and runs alchemy programs over JSON documents. The same command, and the library it is built on, ship in TypeScript, Go, and Rust.

<section class="intro">
<span class="word">dmog</span>
<h1>Translate a document between data formats</h1>
<p class="lede">dmog reads a document in one data format and writes it in another: CSV as YAML, YAML as TOML, an ABNF grammar as GBNF. It writes as it reads, so a large document starts to come out before the end of it goes in. It also runs programs in the alchemy language over a document, to reshape it on the way.</p>
<p class="actions"><a class="button primary" href="/tutorials/first-translation.html">Take the tutorial</a> <a class="button" href="/how-to/install.html">Install dmog</a></p>
<p class="meta">dmog 0.4.0 · MIT licensed · <a href="https://github.com/tabnas/dmog">github.com/tabnas/dmog</a></p>
</section>

Here dmog reads a YAML file and writes it as TOML:

```console
$ cat server.yaml
server:
  host: example.com
  port: 8080
  tls: true
paths:
  - /api
  - /health
$ dmog translate --from yaml --to toml server.yaml
"server" = { "host" = "example.com", "port" = 8080, "tls" = true }
"paths" = [ "/api", "/health" ]
```

The output is the same document in another format. Every format dmog reads, it also writes, and the [formats reference](https://dmog.tabnas.dev/reference/formats.html) lists what each one keeps.

## Install

dmog is one command with three builds. Each needs its own runtime:

| Runtime | Command |
|---|---|
| Node.js 24 or later | `npm install -g @tabnas/dmog` |
| Go | `go install github.com/tabnas/dmog/go/cmd/dmog@latest` |
| Rust 1.85 or later | `cargo install tabnas-dmog` |

For more information, see [Install dmog](https://dmog.tabnas.dev/how-to/install.html).

## Call it from a program

Each build's package is also a library, which a program can call to translate a document or run a program without starting the command. See [Use the TypeScript library](https://dmog.tabnas.dev/how-to/use-the-typescript-library.html), [Use the Go library](https://dmog.tabnas.dev/how-to/use-the-go-library.html), or [Use the Rust library](https://dmog.tabnas.dev/how-to/use-the-rust-library.html).

## The documentation

The documentation is in four parts:

- [Tutorials](https://dmog.tabnas.dev/tutorials/). Lessons that take you from nothing to a working translation, and to a first program.
- [How-to guides](https://dmog.tabnas.dev/how-to/). Recipes for one task each, such as translating part of a document, reading a failure in a script, or calling dmog from a program.
- [Reference](https://dmog.tabnas.dev/reference/). The commands, their options, every format, every failure, and the libraries, stated in full.
- [Explanation](https://dmog.tabnas.dev/explanation/). How dmog is put together, and why it streams.
