YAML para JSON

O Conversor YAML para JSON pega em qualquer documento YAML válido e converte-o em JSON corretamente formatado. Usa o parser padrão js-yaml, então âncoras (&ref / *ref), strings multi-linha (|, >), arrays e objetos aninhados, e a coerção completa de tipos do YAML (números, booleanos, datas, null) convertem corretamente. Cola o teu YAML e o JSON aparece enquanto escreves — sem upload, nada sai do teu browser.

Built by Bob Article by Lace QA by Ben Shipped
Indent
JSON
JSON appears here as you type…

Como usar

  1. 1

    Cola o teu YAML na caixa de entrada. A indentação importa em YAML.

  2. 2

    A saída JSON aparece em baixo enquanto escreves. Se o teu YAML for inválido, vês a mensagem de erro do parser.

  3. 3

    Escolhe indentação de 2 ou 4 espaços para a saída JSON. 2 é a mais comum.

  4. 4

    Toca em Copiar para obter o JSON.

Perguntas frequentes

Ratings & Reviews

Rate this tool

Sign in to rate and review this tool.

Loading reviews…

What YAML and JSON Are, In Two Paragraphs

JSON is the format every API speaks — strict, machine-friendly, brittle when humans edit it. Mismatched braces, trailing commas, and missing quotes will all reject. YAML is the format every config file speaks — whitespace-sensitive, comment-friendly, easy to write by hand. Kubernetes manifests, GitHub Actions workflows, Docker Compose, Ansible playbooks: all YAML. Almost every modern devops tool is a YAML loader at heart.

YAML is technically a superset of JSON — every JSON document is also valid YAML. The reverse is not true: YAML adds anchors, multi-line strings, type coercion, and comments that JSON has no syntax for. The YAML to JSON Converter handles the strict-superset translation by parsing YAML with the standard js-yaml library and serializing the resulting object as JSON.

How the Microapp YAML to JSON Converter Works

Paste any YAML into the input box and the JSON output appears below as you type. There's no Convert button — the conversion runs on every keystroke because the parsing is fast (microseconds even for thousands of lines). Pick 2-space or 4-space indent for the JSON output; everything else (sorting, type preservation, escaping) follows the JSON spec.

The conversion happens entirely in your browser. The js-yaml library runs as JavaScript locally; nothing is uploaded to a server, logged, or stored. Your YAML — which often contains secrets, internal hostnames, and infrastructure details — never leaves your machine.

Worked example. Paste this Kubernetes-style snippet:
name: api
replicas: 3
env:
  - name: DB_URL
    value: postgres://localhost

Output: {"name":"api","replicas":3,"env":[{"name":"DB_URL","value":"postgres://localhost"}]} (formatted with 2-space indent in the actual tool).

What YAML Adds That JSON Doesn't Have

Comments. Lines starting with # are documentation — useful for explaining a config to your future self. JSON has no comment syntax (the spec is famously strict about this). Comments are stripped during conversion because the JSON output has nowhere to put them.

Anchors and references. &default defines a reusable block; *default references it. Useful for DRY config. The JSON output expands references inline — JSON has no anchor syntax, so the converter resolves them.

Multi-line strings. The pipe (|) preserves newlines; the greater-than (>) folds them into spaces. Both convert into ordinary JSON strings with the right whitespace.

Type coercion. Bare yes becomes true, 1.0 becomes a number, 2023-12-25 becomes a date string. JSON has no equivalent guessing — every value is exactly its declared type. The converter resolves YAML's coercions and outputs the typed JSON value.

What JSON Adds That YAML Doesn't Have

Honestly, not much. JSON is intentionally narrower than YAML — the strictness is a feature for machine-to-machine communication. The one thing JSON has that bare YAML doesn't is the strict guarantee of unambiguous parsing: a JSON document parses to exactly one tree, every time, by every parser. YAML has had ambiguity bugs for years (the famous "Norway problem" where unquoted NO parses as boolean false instead of the country code).

Common Conversion Pitfalls

Mixing tabs and spaces. YAML is whitespace-sensitive and disallows tabs in indentation. If your YAML has a tab character mixed in, parsing fails with a confusing error. The conversion error message tells you the line and column.

Unquoted strings that look like dates or numbers. Common gotcha: version: 2.10 parses as the number 2.1 (trailing zero dropped), not the string "2.10". Quote them: version: "2.10".

The Norway problem. Country codes like NO, YES, ON, OFF coerce to booleans in YAML 1.1. Always quote two-letter strings if you mean them as strings: country: "NO".

Duplicate keys. YAML allows duplicate keys in some implementations. The js-yaml parser warns; the JSON output keeps the last duplicate. If your YAML has duplicates, you have a different problem.

Related Tools

For the reverse direction (JSON to YAML), use the JSON to YAML Converter — they form a complete bidirectional codec. To pretty-print or validate JSON without converting to YAML, the JSON Formatter is the right tool. To convert JSON to a flat tabular format, see JSON to CSV or its inverse CSV to JSON. To compare two JSON documents structurally, the JSON Diff handles the diff.