oktools

JSON to YAML, YAML to JSON & TOML Converter

Convert JSON to YAML, YAML to JSON, and either one to or from TOML — the formats behind Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Cargo.toml and pyproject.toml. Integers stay integers, floats keep their decimal point, dates stay dates and keys keep their order, and a syntax error names its line and column. Paste a document or open a file; everything runs in your browser and nothing is uploaded.

JSON → YAML · 18 lines in, 20 lines out

How data types convert between JSON, YAML and TOML

ValueJSONYAMLTOML
Text"checkout"checkout, quoted only when needed"checkout", 'C:\path'
Integer808080808080, 64-bit
Float2.02.0, .inf, .nan2.0, inf, nan
Booleantruetruetrue
NullnullnullNone — left out on request
Date and timeA string2026-10-17T09:30:00Z2026-10-17T09:30:00Z
List[1, 2]- 1 items[1, 2], or [[table]] for objects
Object{ "a": 1 }a: 1 blocks[table] sections, { a = 1 } in lists
CommentsNone# note — not carried over# note — not carried over

How it works

All three formats are read into one shared model before anything is written, and it keeps the distinctions a configuration converter is judged on. Integers are held as bigints and floats as numbers, so 1 and 1.0 stay different and a 64-bit ID is carried exactly rather than rounded. Tables are ordered maps, so keys come out in the order they went in, including keys that look like numbers, which a plain JavaScript object would move to the front. A TOML or YAML date is kept as the text it was written in, since a Date object cannot tell a local time from one with an offset.

JSON is parsed by a strict RFC 8259 reader written for this page, which names the actual mistake, a trailing comma, single quotes, a comment or a missing comma between two lines, with its line and column. YAML goes through the yaml library as YAML 1.2 with the core schema plus a timestamp tag, so an unquoted 2026-10-17 becomes a date; anchors, aliases and << merge keys are expanded and a note says so, and several documents separated by --- become one array. TOML is parsed as TOML 1.0, keeping all four date and time kinds apart.

Writing is done by hand as well, so the output reads as a person would write it. YAML is block style, with a string quoted only when a parser, including a YAML 1.1 one, would misread it, and multi-line text written as a | block. TOML puts a table’s plain keys first, then [table] and [[array of tables]] sections, using single-quoted literal strings for backslashes and triple quotes for several lines. JSON is indented by two or four spaces or minified. A value the target cannot hold, null or a top-level array in TOML, NaN in JSON, stops with a message naming its path.

Examples

Convert JSON to YAML

The strings 1.0 and yes are quoted, because unquoted a YAML parser would read them as a float and, in YAML 1.1, a boolean; name needs no quotes. The float 1.0 is written with its decimal point so it stays a float, and 8080 stays an integer.

JSON
{"name": "api", "version": "1.0", "port": 8080, "ratio": 1.0, "enabled": "yes", "tags": ["web", "api"]}
YAML
name: api
version: '1.0'
port: 8080
ratio: 1.0
enabled: 'yes'
tags:
  - web
  - api

Convert YAML to TOML with tables

The nested mapping becomes a [database] table and the list of mappings becomes two [[replicas]] entries, the layout Cargo.toml and pyproject.toml use, rather than one long inline table.

YAML
service: checkout
database:
  host: db.internal
  port: 5432
replicas:
  - region: eu-west-1
    weight: 0.6
  - region: us-east-1
    weight: 0.4
TOML
service = "checkout"

[database]
host = "db.internal"
port = 5432

[[replicas]]
region = "eu-west-1"
weight = 0.6

[[replicas]]
region = "us-east-1"
weight = 0.4

Convert TOML with dates and a large integer to JSON

JSON has no date type, so both dates become strings and a note under the output says so. version keeps its .0, and id, which is 2^53 + 1, is written exactly where JSON.stringify would have produced 9007199254740992.

TOML
when = 1979-05-27T07:32:00-08:00
day = 1979-05-27
count = 2
version = 2.0
id = 9007199254740993
JSON
{
  "when": "1979-05-27T07:32:00-08:00",
  "day": "1979-05-27",
  "count": 2,
  "version": 2.0,
  "id": 9007199254740993
}

See why TOML refuses a null

The message names the path of the value TOML cannot hold. Ticking the box, or pressing the button in the error panel, writes a = 1 and notes that 1 null value was left out.

JSON
{"a": 1, "b": null}
Result
TOML has no null, so b cannot be written. Give it a value, remove it, or tick "Leave out null values".

Supported formats

  • JSON (RFC 8259)Strict: no comments, trailing commas or single quotes, each of which is named when found, and a leading byte-order mark is ignored. Output is indented by 2 or 4 spaces, or minified onto one line.
  • YAML 1.2Block and flow styles, anchors, aliases and merge keys (expanded on reading), multi-document streams (combined into an array) and unquoted RFC 3339 dates and times read as dates. Output is block style, safe for YAML 1.1 readers.
  • TOML 1.0Tables, dotted keys, arrays of tables, inline tables, literal and multi-line strings, 64-bit integers, floats with inf and nan, and offset date-times, local date-times, local dates and local times.
  • FilesOpen or drop a .json, .yaml, .yml or .toml file up to 5 MB; the input format follows the extension, and a pasted document’s format is detected from its text. The output downloads with the matching extension.
  • Output optionsSort keys A–Z at every depth, choose the indent, and leave out null values when writing TOML.

Use cases

  • Convert a Compose file or a Kubernetes manifest to JSONFor a JSON Schema validator, a jq pipeline or an API that takes the document as a request body, minified onto one line.
  • Move settings between Cargo.toml, pyproject.toml and a YAML CI fileTranslate the same configuration between the formats the tools around a project expect, with tables laid out the way those files are written.
  • Read a YAML file with anchors as plain dataExpanding &defaults and <<: *defaults shows what each job or service actually ends up with once the aliases are resolved.
  • Check that a hand-edited file still parsesThe error panel names the line and column, shows the line with a caret under it and selects it in the input.
  • Normalise key order before a diffSort keys A–Z in both versions of a file and compare the results with the Text Compare tool, so only real changes show.

Limitations

  • Comments do not survive# lines in YAML and TOML are dropped on reading and never written, because the model holds values, not source text. Keep the original file if its comments matter.
  • Anchors come out expandedA YAML alias is written as a full copy in every format, YAML included, so a file that relied on &defaults for brevity grows; the note under the output says when that has happened.
  • One YAML document outSeveral input documents become one array, and the writer cannot produce a --- separated stream. Split the array yourself if the destination expects a multi-document file.
  • Format rules are enforced, not worked aroundNull and a top-level array cannot be written to TOML, and NaN or infinity cannot be written to JSON. Each stops with a message naming the value, apart from nulls, which can be left out on request.
  • JSON5 and JSONC are not readComments and trailing commas in a JSON input are reported as syntax errors with their position, not accepted. Strip them first; a file with # comments can be read as YAML instead.

Frequently asked questions

How do I convert JSON to YAML?

Paste the JSON into the input with JSON selected above it and YAML selected above the output; the YAML appears as you type. Objects become indented key: value blocks, arrays become lists of "- " items, and every key keeps the order it had in the JSON. Strings are left unquoted wherever YAML would read them back as the same text, and quoted wherever it would not — "yes", "1.0", "2026-10-17" and "null" all stay strings rather than turning into a boolean, a float, a date and nothing. Text with line breaks is written as a | block, the way a person would write it by hand.

How do I convert YAML to JSON?

Select YAML for the input and JSON for the output, or simply paste: a pasted document is recognised and the input format switches to match. Comments are dropped, since JSON has none; anchors and aliases (&name and *name) are expanded into copies, and << merge keys are applied. A file holding several documents separated by --- becomes one JSON array with a document per item. The output can be indented by two or four spaces, or minified onto a single line for a request body.

Can it convert JSON or YAML to TOML?

Yes, with three rules that come from TOML itself. The document has to be a table at the top level, so a bare array must be put under a key first. TOML has no null, so a null value stops the conversion and names where it is, unless you tick "Leave out null values". And a table lists its plain keys before its sub-tables, because a key written after a [header] belongs to that header — so some keys can move up, which the tool tells you about. Nested objects become [table] sections, and arrays of objects become [[array of tables]] sections, as Cargo.toml and pyproject.toml are written.

Are data types preserved between JSON, YAML and TOML?

Yes, as far as the target format can hold them. Integers and floats are kept apart, so a version: 2.0 stays 2.0 rather than becoming the integer 2, and integers are carried exactly, including 64-bit IDs above 2^53 that most JavaScript tools round. TOML dates and times arrive in YAML as unquoted timestamps and come back as dates, while JSON, which has no date type, gets them as strings. Booleans stay booleans, and a quoted "02134" stays a string with its leading zero. The one loss is NaN and infinity, which JSON cannot express, so the tool says which value is the problem instead of writing something else.

Why does my YAML or TOML fail to parse?

The error names the line and column where the parser stopped and shows that line with a marker under it; "Show line" selects it in the input. In YAML the usual causes are a tab used for indentation, a child indented by a different amount than its siblings, a value containing ": " that needs quotes, or the same key twice in one mapping. In TOML they are a string without quotes, a table defined twice, or a key set again after its table was closed. In JSON they are a trailing comma, single quotes, a comment or a missing comma between two lines — each of which the message names.

Which YAML and TOML versions does it support?

YAML 1.2 with the core schema, which is what modern parsers and the YAML specification use, and TOML 1.0. When writing YAML the output also stays safe for older YAML 1.1 readers such as PyYAML and go-yaml v2: words like yes, no, on, off, y and n are quoted, so they are not read as booleans, and a time like 07:32:00 is quoted so it is not read as a base-60 number. That keeps Kubernetes manifests, Docker Compose files and GitHub Actions workflows meaning what you wrote.

Is my configuration uploaded anywhere?

No. The whole conversion is JavaScript running in your own browser, so the configuration files you paste or open — with whatever hostnames, keys and passwords are in them — are never sent over the network, written to a log or attached to an analytics event. You can confirm it by opening the network tab and watching it stay empty while you work.