Ferramentas Guias
developer Gratuito Sem cadastro

Conversor JSON ↔ YAML

Converta entre JSON e YAML instantaneamente no seu navegador.

Carregando ferramenta…

Sobre esta ferramenta

Cole JSON ou YAML em qualquer painel e obtenha uma conversão instantânea no outro. Suporta objetos, arrays, strings, números, booleanos e null. Escolha indentação de 2 ou 4 espaços e copie o resultado com um clique.

Como usar

  1. 1 Etapa 1: Cole seu JSON no painel esquerdo — o YAML aparece à direita automaticamente.
  2. 2 Etapa 2: Ou cole YAML no painel direito — o JSON aparece à esquerda.
  3. 3 Etapa 3: Escolha 2 ou 4 espaços para indentação usando o botão de alternância acima dos painéis.
  4. 4 Etapa 4: Clique em Copiar em qualquer painel para copiar o resultado para sua área de transferência.

JSON and YAML: the same data, two notations

JSON and YAML both describe the same underlying structures — objects (key/value maps), arrays (ordered lists), strings, numbers, booleans, and null. They differ only in how that structure is written on the page. JSON uses explicit braces, brackets, quotes, and commas, which makes it unambiguous for machines but noisy for humans. YAML uses indentation and dashes instead of brackets, which makes it cleaner to read and edit by hand. Because the data model is shared, converting between them is a matter of re-rendering the same tree in the other syntax, not changing what the data means. This tool converts JSON to YAML, and with the swap button, YAML back to JSON.

How the conversion works

Converting JSON to YAML happens in two steps. First the tool parses your JSON text into an in-memory data structure — this is also your validation step, because invalid JSON fails to parse and the tool shows the error. Second, it walks that structure and writes YAML: objects become key: value lines, arrays become - item lines, and nesting is expressed by indentation (2 or 4 spaces, your choice). Going the other direction, the tool parses the indentation-based YAML into the same kind of structure and serialises it back out as JSON.stringify with your chosen indent.

A key subtlety is string quoting. Most strings in YAML need no quotes, but some must be quoted to avoid being misread. The tool automatically quotes a string when it is empty, contains YAML-special characters (such as : # [ ] { } , & *), looks like a boolean or number (true, no, 42), or contains a newline. This prevents the classic bug where the value no is silently interpreted as the boolean false.

A worked example

Paste this JSON:

{ "name": "api", "ports": [80, 443], "tls": true }

With 2-space indentation the tool produces:

name: api
ports:
  - 80
  - 443
tls: true

Notice the braces, brackets, quotes, and commas are gone. The object's keys become plain lines, the array becomes a dashed list indented under ports, and the boolean stays unquoted. Click swap and the YAML round-trips back to equivalent JSON.

The trap that makes YAML famous: indentation

In JSON, structure is defined by brackets, so whitespace is cosmetic. In YAML, indentation is the structure. Two spaces vs. three spaces, or a stray tab, changes which object a key belongs to. The two most common YAML mistakes are:

  • Tabs instead of spaces. YAML forbids tabs for indentation. Always indent with spaces — this tool emits spaces and you should too.
  • Inconsistent indent levels. Mixing 2-space and 4-space indentation in the same file breaks parsing. Pick one (the radio buttons here let you standardise) and keep it consistent.

Scope and limitations

This is a lightweight, dependency-free converter built for the common cases you meet in config files: nested objects, arrays, scalars, and the standard quoting rules. It does not implement every corner of the YAML 1.2 specification — advanced features such as anchors and aliases (&/*), explicit type tags, multi-document streams (--- separators), and multi-line block scalars (| and >) are outside its scope. For routine API payloads, Kubernetes-style manifests, and CI configuration it handles the job; for exotic YAML, validate with a full parser.

Use cases and privacy

  • Config conversion. Turn a JSON settings file into the YAML many tools and CI systems prefer.
  • Readability. Convert a dense JSON response to YAML to read or diff it more easily, then convert back.
  • Learning. Paste familiar JSON and watch the YAML equivalent to learn the syntax mapping.
  • Quick validation. Because conversion requires parsing, a successful convert confirms your JSON or YAML is well-formed.

Both directions run entirely in your browser. Your data — which often includes API keys, hostnames, or internal config — is never uploaded, so the tool works offline and keeps sensitive values on your own machine.

Perguntas frequentes

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}