This page's code did not start.

Opening index.html directly from a folder blocks JavaScript modules, so nothing will happen when you choose a file. Serve the folder over http instead:

powershell -ExecutionPolicy Bypass -File serve.ps1

Then open http://localhost:8080/.

YAML to JSON — and JSON back to YAML

Both directions, and it says what each one costs. Nothing is pasted into anyone else's server.

Language: English
View source
Your YAML and JSON are processed in your browser. No processing upload.

Converting is arithmetic over a string, done here, in this page. The two parsers are hand-written and in src/ — shared/parse-yaml.js and shared/parse-json.js — and there is nothing else. This tool has no network feature of any kind — nothing to fetch, nothing to send — which matters more here than almost anywhere on this site: a YAML file is usually a deployment config, and a deployment config is usually full of hostnames, bucket names and secrets.

Live check: checking…

Offline: checking…

Don't take our word for it: open DevTools, watch the Network tab, and convert something. Not one request carries a character of what you pasted. Or unplug from the internet and convert it anyway.

1 Pick the direction

Indentation A tab is offered only for JSON. YAML is defined in terms of spaces and a tab is not legal indentation in it.

Sort the keys of every object By how the keys read rather than by their code points, so item2 comes before item10.

2 Paste it in

empty

3 Take the result

Nothing yet.

 

View as Markdown

How to convert YAML to JSON without uploading it

  1. Pick the direction. YAML to JSON or JSON to YAML. The note under the menu says what that direction loses before you paste anything, rather than after.
  2. Paste it in, or drop the file. Anything you can select and copy works. A file dropped on the picker is read by your own browser and put in the box — there is no upload step to leave out — and a .json or .yaml extension sets the direction for you.
  3. Choose the indentation. Two spaces, four, or a tab. The tab is offered for JSON only: YAML is defined in terms of spaces, and a tab is not legal indentation in it.
  4. Read the error where the error is. A parser that fails here says what it found and on which line and column, rather than “unexpected token at position 4193”. That is usually enough to fix a config file without opening anything else.
  5. Take the result. Copy it, or download it as a file, named for the format it came out in.

The longer version

How to convert between YAML and JSON Convert a supported YAML subset to JSON, or JSON to YAML, in your browser. Check comment loss, unsupported constructs and exact number text before reuse.

Questions

Is my YAML uploaded anywhere?

No. Both parsers and both printers on this page are functions that run in your own browser, on your own hardware. This tool has no network feature of any kind — it never fetches anything and never sends anything — and the page's Content-Security-Policy names every address it may contact, none of which belongs to this site. That is the reason to use it for a deployment config: those are full of hostnames, bucket names and occasionally a secret somebody meant to move, and pasting one into somebody else's converter is giving it to them.

What does converting YAML to JSON lose?

JSON drops comments. This parser deliberately supports a subset of YAML 1.2 and refuses anchors, aliases and tags instead of choosing an expansion or type conversion for you. JSON represents a tree of values; YAML can represent shared nodes and typed values. Multi-document streams are also refused rather than wrapped in an invented array. JSON to YAML keeps the represented values. The YAML specification defines the broader format.

My YAML says no and the JSON came out as a string. Why?

YAML 1.1 treated yes, no, on and off as booleans, turning Norway’s country code into false. This supported subset uses YAML 1.2 rules: those words stay strings, true and false are booleans, null and ~ are null, and numeric scalars are numbers. The YAML writer quotes the ambiguous words for readers that still use older rules.

Does it keep the order of my keys?

Yes, in both directions, and that is harder than it sounds. A converter built on JSON.parse silently moves integer-like keys to the front, so {"10":a,"2":b} comes back as {"2":b,"10":a}. Numbers keep the digits you typed, so a twenty-digit account id does not lose its last three to a double. If you want them sorted there is a checkbox, and it sorts by how the keys read rather than by their code points.

Can it convert several YAML documents at once?

No, and it says so rather than picking one. A file with --- separators holds more than one document, and JSON has no shape that means “several documents” — an array would be a claim the file never made. Convert them one at a time.

Why is there no YAML formatter here?

Because YAML has no squeezed form worth writing — the short one is flow style, which is unreadable, and unreadable is the opposite of the reason to keep a file in YAML. Laying out JSON, XML, HTML and CSS is the JSON formatter's job, and it lays out YAML too.

How big a file can it handle?

There is no limit set here, because there is no server paying for one. The practical ceiling is your own machine: a few megabytes of YAML is fine, and the page waits for a pause in your typing before it converts a very long document rather than fighting you for the keyboard.

Is it free, and do I need an account?

It is free, and there is no account, no sign-in, no trial and no limit on how much you paste. The site carries advertising, which is what pays for it; the ads are not given anything about your text.

Does it work offline?

Yes. Load the page once, then disconnect from the internet and it keeps working. That is also the simplest way to prove nothing is being uploaded: a tool that sent your config away to be converted would stop the moment you unplugged.