JSON to YAML Converter
Keep exact numeric tokens, control string quoting, and check that YAML reads back as the same data.
Runs locally in your browser. Nothing is uploaded or sent to a server.
Paste valid JSON into JSON Input to get YAML automatically in YAML Output. Choose 2 spaces or 4 spaces, and enable Quote all strings to double-quote every string and key. The converter preserves original numeric tokens, including large integers and decimal precision. Its Round-trip check reads the output back with YAML 1.2 core rules and identifies changed values or duplicate keys. Conversion runs locally in your browser without uploading your input.
Updated
Related Tools
YAML to JSON
Choose YAML scalar rules, inspect type changes, and export single or multi-document JSON locally.
developer-toolsJSON Formatter
Beautify or minify JSON, inspect its structure, and copy or download the result in your browser.
developer-toolsJSON Validator
Check JSON as you type, locate syntax errors, and inspect duplicate keys, key counts and nesting depth.
developer-toolsJSON Minifier
Minify and compress JSON in your browser. Remove whitespace, indentation and line breaks. Your data stays on your device.
developer-toolsCron Expression Parser
Explain Standard, Quartz, and AWS schedules with field details and up to eight local and UTC run times.
developer-toolsMarkdown to HTML
Turn Markdown into sanitized HTML, preview it, and export a fragment or full document.
How do you convert JSON to YAML while keeping values intact?
Paste the JSON below into JSON Input, leave Indent at 2 spaces, and keep Quote all strings unchecked. YAML Output updates automatically. This example combines a nested object, a sequence, an exact integer, a string that resembles a boolean, and an empty collection so you can inspect more than indentation alone.
{
"service": {
"name": "worker",
"enabled": true,
"replicas": 3
},
"regions": ["east", "west"],
"id": 9007199254740993,
"mode": "on",
"extras": []
}
The generated YAML is:
service:
name: worker
enabled: true
replicas: 3
regions:
- east
- west
id: 9007199254740993
mode: "on"
extras: []
The integer keeps its original digits. The string on gains double quotes, while the boolean true stays unquoted. The expected status is Round-trip check: identical. Enable Quote all strings and the keys and ordinary string values gain quotes too; replicas remains a number. Copy the result after checking this status.
How does JSON to YAML conversion work?
The tool parses the input into a tree using a lossless JSON parser. Numeric tokens are retained as text rather than first being rounded into JavaScript numbers. A recursive serializer then emits YAML mappings for objects, sequences for arrays, and scalar representations for strings, numbers, booleans, and null. Minified input follows the same process as indented input.
This distinction matters for identifiers, precise decimals, and exponent notation. A token such as 1.0000000000000001 is emitted with the same digits, and 1e400 stays in exponent form. Preservation happens at conversion time: if an upstream program has already rounded a value, this tool receives only that rounded text. Its output cannot restore missing precision or change how your destination application stores numbers.
Which strings need quotes in YAML?
Plain YAML scalars can acquire types when a parser reads them. The converter quotes strings resembling booleans or null, including yes, no, y, n, and ~. It also quotes numeric-looking strings, date-shaped strings, whitespace at either end, and strings containing YAML punctuation such as a colon or hash. The same quoting rules apply to object keys.
Automatic quoting is deliberately conservative. A colon triggers quoting even when it would be harmless in a particular position. Quote all strings makes the policy simpler to review: every key and string value uses escaped double quotes. It does not quote actual JSON numbers, booleans, or null. Choose the setting your configuration review process prefers, then check the decoded result rather than treating quotation marks as a change in the original data.
How do JSON and YAML represent the same data?
JSON uses explicit braces and brackets for containers. YAML block style expresses their hierarchy through indentation and sequence dashes. The converter changes that representation while keeping the data model. This table describes its output rather than every feature allowed by the YAML specification.
| JSON input type | YAML representation | Detail to check |
|---|---|---|
| Object | Mapping with colon-separated keys | Empty object stays {} |
| Array | Sequence with dashes | Empty array stays [] |
| String | Plain, double-quoted, or literal block | Ambiguous text is quoted |
| Number | Original numeric token | Digits and exponent spelling are retained |
| Boolean or null | true, false, or null | These remain typed values |
YAML supports comments, but strict JSON input does not. Conversion cannot carry source comments that JSON never contained. Nor does the serializer invent anchors, aliases, folded text, or application-specific configuration sections. For the reverse direction, use YAML to JSON Converter.
How are indentation and multiline strings handled?
Indent offers 2 spaces, the default, or 4 spaces. Both use spaces rather than tabs. Changing the setting changes emitted nesting indentation, not the contents of string values. Matching a repository's existing style makes the converted configuration easier to review alongside surrounding files.
A multiline value without a trailing newline uses the literal block indicator |-. For example, the JSON string "hello\nworld" becomes a two-line block whose decoded value has no final newline. A string ending in a newline instead uses escaped double quotes, so the final break remains explicit. Quote all strings also switches multiline values to escaped double quotes. This is significant when a script or template distinguishes text with and without a final line break.
What does the round-trip check catch?
After serialization, the checker reads the YAML using YAML 1.2 core scalar rules and compares it with the original JSON tree. It checks object entries, array items, scalar types and values, and the presence of exactly one YAML document. Numeric comparison uses exact decimal normalization, so equivalent exponent forms compare without floating-point coercion.
Duplicate object keys deserve special attention. For {"x":1,"x":2}, the emitted mapping retains the last value, but the check reports that the duplicate JSON key cannot be retained. A changes detected status also lists paths for values that differ or reports a parsing failure. An identical result verifies this conversion against the built-in parser; it does not verify required fields, allowed values, or the schema used by your deployment system.
What input errors and size limits should you expect?
Input must contain one complete JSON value. Comments, trailing commas, unquoted keys, and single-quoted strings are rejected. Errors appear beneath the panels with a JSON Error label; parser diagnostics include a line and column. Empty or whitespace-only input clears the result. Use JSON Validator when you need to investigate the source separately.
The JSON parser stops containers beyond 512 nesting levels. The round-trip YAML reader has a separate nesting guard of 100 and a 2 MiB UTF-8 input limit, so conversion output can exist while verification reports a limit failure. There is no file-upload control or configurable batch queue here. Large pasted documents also depend on browser memory and processing time; the byte count describes output size, not a promise that every destination accepts it.
When should you use the result in a configuration file?
Use conversion to avoid manually rewriting an existing JSON object into YAML, then adapt the result to the receiving application's requirements. An API response does not become a valid deployment manifest merely by changing syntax. Check required fields, nesting, and types before use. The output panel supplies line and byte counts and Copy to clipboard; Share appears on platforms that support file sharing.
Parsing, serialization, and verification run in the browser without uploading the entered text. Paste requests clipboard access; if permission is unavailable, paste directly into JSON Input. Review sensitive values before deliberately sharing them through the platform share sheet. Clear empties the input when you finish.
How to Use JSON to YAML Converter
-
JSON Input
Type or paste valid JSON into JSON Input. Paste reads the clipboard when permission is available; Sample inserts example data, and Clear empties the input.
-
Indent
Choose 2 spaces or 4 spaces under Indent. Output updates automatically; there is no separate conversion button.
-
Quote all strings
Enable Quote all strings to double-quote every string value and object key. Leave it unchecked for automatic quoting of ambiguous strings.
-
Round-trip check
Review Round-trip check for identical or changes detected, then use Copy to clipboard in YAML Output. Check any listed paths before using the result.