JSON ↔ YAML Converter
Two-way JSON ⇄ YAML conversion that keeps numbers exact and warns about YAML traps.
Converted as you type. You can also drop a .json, .yaml or .yml file here — it is read on your device, never uploaded.
Warnings
About the JSON ↔ YAML Converter
Turn JSON into readable YAML for a config file, a Kubernetes manifest or a CI pipeline — or turn YAML into JSON for an API, a script or jq. Both directions run in your browser and keep your data exact: integers such as 12345678901234567890 are not rounded, and 1.10 stays 1.10.
YAML has traps that JSON does not. Older YAML 1.1 parsers — PyYAML and Ruby's Psych, for example — read yes, no, on and off as booleans (so the country code NO becomes false, the "Norway problem"), 0755 as an octal number and 22:22 as a base-60 number. When converting JSON to YAML, such strings are quoted so that every parser reads them the same way. When converting YAML to JSON, each risky value is listed with its line and column, and multi-document files (---), anchors, aliases and << merge keys are handled.
How to use it
- Choose JSON → YAML or YAML → JSON, then paste your text, open a file (
.json,.yaml,.yml) or press Load sample. The result updates as you type. - For YAML output, pick the indentation, the style (block, block with one-line lists, or flow) and how strings are quoted; keep Safe for YAML 1.1 parsers on unless you know every reader supports YAML 1.2.
- For JSON output, pick the layout (2 spaces, 4 spaces, tabs or minified), and whether to use YAML 1.1 rules, merge keys and CloudFormation tags.
- Read the warnings: each shows the line and column and what another parser would make of the value. Show jumps to it.
- Copy or download the result, or press Use as input to convert it back.
Examples
{"country": "NO", "mode": "0755", "debug": "off", "version": "1.10", "id": 12345678901234567890}country: "NO" mode: "0755" debug: "off" version: "1.10" id: 12345678901234567890
Without the quotes, PyYAML would read false, 493, false and the number 1.1.
kind: Service --- kind: Deployment
[{"kind":"Service"},{"kind":"Deployment"}]Shown with the Minified layout; the default layout indents with 2 spaces.
base: &base restart: always web: <<: *base image: nginx
{"base":{"restart":"always"},"web":{"restart":"always","image":"nginx"}}BucketName: !Sub "${AWS::StackName}-logs"
Arn: !GetAtt MyQueue.Arn{"BucketName":{"Fn::Sub":"${AWS::StackName}-logs"},"Arn":{"Fn::GetAtt":["MyQueue","Arn"]}}Common uses
- Writing Docker Compose, Kubernetes, GitHub Actions or Ansible files from JSON you already have.
- Feeding YAML configuration to tools and APIs that only accept JSON.
- Converting CloudFormation YAML templates to JSON (and back) without losing
!Refand!Sub. - Checking whether a YAML file means the same thing in PyYAML, Ruby and JavaScript parsers.
YAML 1.1 versus YAML 1.2
YAML 1.2 reads only true/false as booleans and 0o755 as octal. Many widely used parsers still follow YAML 1.1, where these plain values mean something else:
yes,no,on,off(any capitalisation PyYAML accepts, e.g.Yes,NO) → booleans; YAML 1.1's own rules also includeyandn.0755→ 493 (octal);0b101→ 5;1_000→ 1000.1:30or22:22→ base-60 numbers (90 and 1342) — a classic port-mapping bug.2001-12-14→ a date object instead of a string.1e5→ a string (PyYAML only treats1.0e+5as a float).
This converter parses YAML as 1.2 by default (choose 1.1 to mimic PyYAML, or put %YAML 1.1 at the top of the file) and warns whenever the two versions disagree about a value.
What happens to YAML features JSON lacks
- Comments are dropped — JSON has none.
- Anchors and aliases (
&base,*base) are expanded into copies. Recursive aliases, and documents whose aliases would expand into more than 200,000 values (a "billion laughs" attack), are refused. - Merge keys (
<<: *base) copy the members of the referenced mapping; members written explicitly win, and in a list of merges the first mapping wins (as in PyYAML). - Tags:
!!str,!!intand the other standard tags are applied; CloudFormation tags become{"Ref": …}and{"Fn::…": …}; other custom tags are dropped with a warning. - Keys that are not text (
1:,true:,~:) become strings, as JSON requires. .infand.nanhave no JSON form and becomenull, with a warning. Dates become strings.
Limitations
- Comments cannot be carried over into JSON, and JSON → YAML output has no comments.
- Custom tags other than CloudFormation's (for example
!includeor!vault) are not executed; their values are kept as plain data. - Very deep nesting (more than 1,000 levels) is refused; very large files (tens of megabytes) are converted in your browser and can take a few seconds.
- Duplicate keys are an error in YAML unless you tick Allow duplicate keys; duplicates in JSON keep their last value.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Is my file uploaded?
No. Conversion runs entirely in your browser, and the page works offline once loaded — fine for configs that contain hostnames or credentials.
Why are some strings quoted in the YAML output?
Because without quotes some parser would read them as something else: "NO" and "on" would be booleans in YAML 1.1, "0755" an octal number, "1.10" the number 1.1, and "123" a number in every YAML version. Untick Safe for YAML 1.1 parsers to quote only what YAML 1.2 requires.
Why does GitHub Actions' on: become "true" in YAML 1.1 mode?
In YAML 1.1, the plain key on is the boolean true — PyYAML reads on: push as {True: "push"}. GitHub reads on as a string. In the default YAML 1.2 mode the key stays "on", and the converter warns about it.
How are multiple documents handled?
A YAML file with several documents separated by --- becomes a JSON array with one item per document. In the other direction, tick Array → separate documents to write each item of a top-level JSON array as its own document.
Are big numbers safe?
Yes. Integers keep every digit in both directions, and decimals are copied exactly as written. Note that JavaScript's JSON.parse would still round integers above 2^53 when a program reads the JSON — the converter points those out.