TOML to JSON / YAML Converter
Save on GoogleTip: drag and drop a .toml file onto the input box.
// Output appears here
Related Developer Tools | |
| Tool Name | Explanation |
|---|---|
| JSON to Go Struct Converter | Generates idiomatic Go structs with json tags from any JSON payload. |
| JSON to TypeScript Interface | Generates typed TypeScript interfaces from any JSON payload. |
| HTML to JSX Converter | Converts HTML markup into valid React JSX (className, self-closing tags, style objects). |
| Binary to Text Converter | Decodes binary (0s and 1s) into readable text and back. |
| Base64 Encode / Decode | Encodes text or files to Base64 and decodes Base64 strings instantly. |
TOML vs JSON vs YAML Syntax Equivalence & Key-Value Spec Table
| Data Concept | TOML Syntax | JSON Equivalent | YAML Equivalent |
|---|---|---|---|
| Comment | # note | not supported | # note |
| Key-value pair | name = "app" | "name": "app" | name: app |
| Bare key | server_port = 8080 | "server_port": 8080 | server_port: 8080 |
| Quoted key | "my key" = 1 | "my key": 1 | "my key": 1 |
| Dotted key | a.b.c = 1 | {"a": {"b": {"c": 1}}} | a: |
| Basic string | s = "hi\n" | "s": "hi\n" | s: "hi\n" |
| Literal string | p = 'C:\path' | "p": "C:\\path" | p: 'C:\path' |
| Multi-line basic string | s = """ | "s": "line1\nline2" | s: |- |
| Multi-line literal string | s = ''' | "s": "raw \\n text" | s: 'raw \n text' |
| Line-ending backslash | s = """a \ | "s": "a b" | s: a b |
| Unicode escape | s = "\u00E9" | "s": "é" | s: "é" |
| Integer | n = 42 | "n": 42 | n: 42 |
| Signed integer | n = +99 | "n": 99 | n: 99 |
| Underscore separators | n = 1_000_000 | "n": 1000000 | n: 1000000 |
| Hexadecimal | n = 0xFF | "n": 255 | n: 255 |
| Octal | n = 0o755 | "n": 493 | n: 493 |
| Binary | n = 0b1010 | "n": 10 | n: 10 |
| Float | f = 3.14 | "f": 3.14 | f: 3.14 |
| Float with exponent | f = 6.02e23 | "f": 6.02e+23 | f: 6.02e+23 |
| Whole-number float | f = 5.0 | "f": 5.0 | f: 5.0 |
| Infinity | f = inf | not representable | f: .inf |
| Not a number | f = nan | not representable | f: .nan |
| Boolean | ok = true | "ok": true | ok: true |
| Offset date-time | t = 1979-05-27T07:32:00Z | "t": "1979-05-27T07:32:00Z" | t: 1979-05-27T07:32:00Z |
| Offset with timezone | t = 1979-05-27T00:32:00-07:00 | "t": "1979-05-27T00:32:00-07:00" | t: 1979-05-27T00:32:00-07:00 |
| Local date-time | t = 1979-05-27T07:32:00 | "t": "1979-05-27T07:32:00" | t: 1979-05-27T07:32:00 |
| Local date | d = 1979-05-27 | "d": "1979-05-27" | d: 1979-05-27 |
| Local time | t = 07:32:00 | "t": "07:32:00" | t: "07:32:00" |
| Array | ports = [8000, 8001] | "ports": [8000, 8001] | ports: [8000, 8001] |
| Multi-line array | hosts = [ | "hosts": ["a", "b"] | hosts: |
| Mixed-type array | m = [1, "a", true] | "m": [1, "a", true] | m: [1, a, true] |
| Nested array | m = [[1, 2], [3]] | "m": [[1, 2], [3]] | m: |
| Empty array | e = [] | "e": [] | e: [] |
| Table | [server] | {"server": {"host": "x"}} | server: |
| Nested table | [a.b] | {"a": {"b": {"c": 1}}} | a: |
| Spaced table header | [ a . b ] | {"a": {"b": {}}} | a: |
| Quoted table name | ["a.b"] | {"a.b": {"x": 1}} | "a.b": |
| Inline table | pt = { x = 1, y = 2 } | "pt": {"x": 1, "y": 2} | pt: |
| Array of tables | [[bin]] | {"bin": [{"name": "a"}, {"name": "b"}]} | bin: |
| Nested array of tables | [[a.b]] | {"a": {"b": [{"x": 1}]}} | a: |
| Sub-table of array item | [[bin]] | {"bin": [{"opts": {"lto": true}}]} | bin: |
| Empty table | [empty] | "empty": {} | empty: {} |
| Null value | not supported | null | null or ~ |
| Duplicate key | error | allowed, last value wins | error in strict parsers |
| Multiple documents | not supported | not supported | --- separator |
| Anchors and aliases | not supported | not supported | &a and *a |
| Indentation | ignored | ignored | significant |
| Root value | always a table | any value | any value |
| File extension | .toml | .json | .yaml or .yml |
| Media type | application/toml | application/json | application/yaml |
| Cargo manifest | [dependencies] | {"dependencies": {"serde": "1.0"}} | dependencies: |
| pyproject.toml | [project] | {"project": {"name": "pkg"}} | project: |
| Hugo config | baseURL = "https://x.com/" | "baseURL": "https://x.com/" | baseURL: https://x.com/ |
Technical Q&A / FAQ Matrix
| Technical Developer Question | Exact Solution & Code Snippet |
|---|---|
| How do I parse TOML in Go? | import "github.com/BurntSushi/toml"; var cfg Config; _, err := toml.DecodeFile("config.toml", &cfg) |
| How do I read TOML in Python 3.11+? | import tomllib; with open("pyproject.toml", "rb") as f: data = tomllib.load(f) |
| How do I deserialize TOML in Rust? | let cfg: Config = toml::from_str(&std::fs::read_to_string("Cargo.toml")?)?; |
| How do I parse TOML in Node.js? | import { parse } from 'smol-toml'; const data = parse(text); |
| How do I convert TOML to YAML on the command line? | yq -p toml -o yaml config.toml |
| How do I convert a Hugo config from TOML to YAML? | hugo convert toYAML -s ./site -o ./site-yaml |
| What happens to TOML dates in JSON? | They become ISO 8601 strings. Revive them with new Date(value). |
| How do I represent null in TOML? | TOML has no null. Omit the key, or use a sentinel such as an empty string. |
| Why do I get a duplicate key error? | TOML forbids defining the same key or table twice. Merge the entries into one table. |
| What happens to inf and nan in JSON? | JSON has no such numbers. This tool writes them as the strings "inf", "-inf" and "nan". |