paste in · yaml out

JSON to YAML Converter — config a human can read

Paste JSON and get YAML that reads like somebody wrote it — 2 or 4 space indent, optional key sorting, and quoting handled for you. Good for Kubernetes, Compose, and CI configs.

Converter — Ready
Awaiting input
idle — paste JSON and the YAML shows up here
0 keys 2-space indent
runs entirely in your browser
nothing is uploaded, ever
no sign-up, no account
free — no paid tier, ever
The basics

What is a JSON to YAML converter?

A JSON to YAML converter takes a JSON document and produces an equivalent YAML file. JSON and YAML are designed to be interchangeable — they represent the same data structures (objects, arrays, strings, numbers, booleans, null) with different syntax. YAML is preferred for configuration files because it's more human-readable, supports comments, and avoids the visual noise of curly braces and quotation marks.

For example, this JSON:

{
  "name": "web-server",
  "image": "nginx:1.25",
  "ports": [80, 443],
  "environment": {
    "DOMAIN": "example.com",
    "DEBUG": false
  }
}

becomes this YAML:

name: web-server
image: nginx:1.25
ports:
  - 80
  - 443
environment:
  DOMAIN: example.com
  DEBUG: false

The data is identical; only the syntax changes. YAML's indentation-based structure is easier to scan and edit by hand, which is why it's become the standard for configuration files in Kubernetes, Docker, Ansible, GitHub Actions, and dozens of other modern tools.

Step by step

How to convert JSON to YAML in 3 steps

Most conversions take less than a minute. No login, no upload to a server, no installation.

  1. Paste or upload

    Drop a .json file into the upload zone, or paste JSON text. The converter parses it instantly and shows the YAML preview.

  2. Configure

    Open the settings cog to choose the indent size (2 spaces for Kubernetes convention, 4 for readability), and whether to sort keys alphabetically.

  3. Copy or download

    Click Copy YAML to put the result on your clipboard, or Download YAML to save a .yaml file. Drop it straight into your project.

Why HopConvert

Built for the YAML you actually need

YAML has subtle rules around quoting, indentation, and key order. HopConvert handles them by default.

YAML 1.2 compliant

Output is valid YAML 1.2, the current standard. Works with every parser: Python, Ruby, Go, Node, Java, Kubernetes, Ansible.

2 or 4-space indent

2-space is the Kubernetes and Docker Compose convention. 4-space is more readable for deeply nested configs.

Smart key sorting

Optional alphabetical sort produces diff-friendly output that doesn't churn in version control when only values change.

Browser-only privacy

Every byte is processed in your browser. Nothing is uploaded, logged, or stored on our servers.

Multi-line strings

Strings with embedded newlines are emitted as YAML block scalars (|). Single-line strings stay on one line.

Live preview

The result panel updates as you type. See exactly what your YAML will look like before downloading.

Comparison

JSON vs YAML: what's the difference?

Both formats store structured data, but they're designed for different jobs.

AspectJSONYAML
SyntaxBraces, brackets, commas, quotesIndentation, colons, dashes
Best forAPIs, data interchange, machine-to-machineConfiguration files, human editing
File sizeSmaller (less whitespace)Larger (indentation is significant)
Human readabilityModerate (visual noise)High (clean, scannable)
CommentsNot supported# comments
ReferencesJSON Pointer (complex)Anchors (&) and aliases (*) — simple
Multi-line stringsRequires \n escapesLiteral block (|) or folded (>)
StandardRFC 8259YAML 1.2 (no RFC)
Use cases

When teams reach for JSON to YAML

YAML is the lingua franca of modern infrastructure. The JSON→YAML conversion unlocks all of it.

Kubernetes manifests

Use kubectl get -o json to dump a resource, then convert it to YAML for editing and committing to a Git repo.

Docker Compose

Compose files are YAML. Generate a base config from a JSON spec, then customise per environment.

GitHub Actions

Convert a CI pipeline from a templating system to YAML, ready to drop into .github/workflows/.

Ansible playbooks

Generate Ansible tasks from an inventory JSON file. Hand-editing YAML is faster than the equivalent JSON.

Helm values

Helm chart values.yaml files are easier to maintain than their JSON equivalents. Convert a config once.

API documentation

Convert an OpenAPI spec from JSON to YAML for human review. Most OpenAPI tooling accepts both.

The complete guide

JSON to YAML: the complete guide

Everything you need to know about the YAML format, the conversion rules, and how to use YAML in real infrastructure.

Read the full JSON to YAML guide

YAML syntax basics

YAML uses three structural markers: indentation for hierarchy, colons for key-value pairs, and dashes for list items. Whitespace is significant — YAML does not use braces or brackets. A simple document:

name: web-server
replicas: 3
image: nginx:1.25
ports:
  - 80
  - 443
labels:
  app: web
  tier: frontend

The indentation (2 spaces per level) creates the hierarchy. A dash followed by a space introduces a list item. A colon followed by a space separates a key from its value. That's the whole syntax — YAML 1.2 is designed to be the most readable structured data format ever standardised.

YAML is also a strict superset of JSON: any valid JSON document is also a valid YAML document. That's what makes the conversion lossless.

How does the conversion work?

JSON has six value types: object, array, string, number, boolean, null. YAML has the same six types, plus extras like timestamps and binary data. The conversion is one-to-one for the shared types, with these rules:

  • Objects become block-style mappings with each key on its own line, indented under the parent.
  • Arrays become block-style sequences with each item prefixed by a dash.
  • Strings stay unquoted unless they contain special characters or look like other types (numbers, booleans, null).
  • Numbers stay as plain digits (no quotes), matching YAML's native number type.
  • Booleans are emitted as true or false (lowercase, the YAML 1.2 canonical form).
  • Null is emitted as null or ~ (both are valid YAML).

JSON keys are always strings, so they become unquoted YAML keys (the standard practice). If a key would be ambiguous (e.g., contains a colon or starts with a number), the converter adds quotes automatically.

When does YAML need quotes?

YAML is permissive about quoting but strict about ambiguity. A string that could be parsed as a number, boolean, or null must be quoted to be treated as a string. Examples:

  • version: 1.0 — parsed as a number unless quoted ("1.0")
  • active: true — parsed as a boolean unless quoted ("true")
  • empty: null — parsed as null unless quoted
  • on: yes — parsed as boolean true (YAML 1.1 compatibility)
  • code: 01234 — parsed as octal in some parsers; quote to be safe

Strings that contain special characters (colons, hashes, leading/trailing whitespace, newlines, leading dashes) also need quoting. HopConvert applies quoting automatically using these rules. Toggle "Quote all strings" in settings if you want every string to be quoted explicitly — useful for diff stability and for users unfamiliar with YAML's ambiguity rules.

Multi-line strings

JSON has no real multi-line string type — embedded newlines must be escaped as \n. YAML supports two block scalar styles:

  • Literal (|): Newlines are preserved exactly. Best for code, configuration blobs, and any text where formatting matters.
  • Folded (>): Newlines become spaces, except for blank lines which become single newlines. Best for prose where you'd otherwise use one long line.

When converting JSON, the converter can't know which style you want (the JSON doesn't encode the difference), so it defaults to literal (|) for any string containing a newline. You can change the default in settings or by post-processing the file.

Anchors and aliases

YAML has a feature JSON lacks: anchors (&name) and aliases (*name). An anchor marks a value for reuse; an alias refers back to it. This is useful for DRY configurations:

defaults: &defaults
  retries: 3
  timeout: 30
production:
  <<: *defaults
  host: prod.example.com
staging:
  <<: *defaults
  host: staging.example.com

JSON has no equivalent, so converting a YAML file with anchors to JSON will inline the values (losing the DRY structure). Converting JSON to YAML can't create anchors automatically — the input has no concept of "this is the same as that." If you need anchors, add them by hand after the conversion.

Kubernetes conventions

Kubernetes uses YAML 1.2 with a few conventions worth knowing:

  • 2-space indent. Always. Tools like kubectl apply and helm install don't care, but humans reading the file do.
  • Lowercase keys. apiVersion, kind, metadata, spec. The schema is case-sensitive.
  • apiVersion first, then kind, then metadata, then spec, then status. Most YAML sorters will reorder keys to this convention; if yours doesn't, do it by hand.
  • Strings with template syntax ({{ .Values.foo }}) should be quoted to avoid YAML's type-coercion rules interpreting .Values.foo as a number.
  • Multi-document YAML (multiple ----separated documents in one file) is common for k8s manifests. The converter doesn't split or merge these — one JSON document becomes one YAML document.

Common edge cases

Most JSON-to-YAML conversions are straightforward, but a few patterns are worth knowing about:

  • Empty objects and arrays: Emitted as {} and [] (flow style). This is the most portable representation across parsers.
  • Empty strings: Emitted as "" (quoted) to distinguish them from null and to make the column width obvious in editors.
  • Unicode: Preserved as-is. YAML is UTF-8 by default, so emoji and non-Latin characters round-trip cleanly.
  • Very long strings: The converter doesn't wrap them. If you need a hard wrap, post-process the output (or use YAML's folded scalar style).
  • Numbers that look like dates: 20241231 stays a number. "2024-12-31" stays a string. YAML 1.2 doesn't auto-parse dates (that's a YAML 1.1 quirk).
  • Trailing whitespace in strings: Preserved. YAML parsers handle this correctly; some text editors may strip it on save.
FAQ

Frequently asked questions

Everything you need to know about converting JSON to YAML with HopConvert.

What is a JSON to YAML converter?
A JSON to YAML converter takes a JSON document and produces an equivalent YAML file. JSON and YAML are designed to be interchangeable: both represent the same data structures with different syntax. YAML is preferred for configuration files because it's more human-readable and supports comments.
Is HopConvert free to use?
Yes. The JSON to YAML converter is 100% free with no sign-up required. There are no paid tiers, no feature gates, and no premium plans. Conversion runs in your browser so we don't pay for servers and we don't charge you.
What is YAML used for?
YAML is the standard format for configuration files in modern infrastructure and deployment tools: Kubernetes manifests, Docker Compose files, Ansible playbooks, GitHub Actions workflows, GitLab CI pipelines, Prometheus alert rules, Helm charts, and many more. It's also used for data serialization and cross-language data exchange.
Is YAML 1.2 supported?
Yes. The converter produces YAML 1.2 output, which is the current standard. YAML 1.2 is a strict superset of JSON, so any valid JSON document is also valid YAML.
How are keys sorted?
By default, keys are kept in the order they appear in your JSON document. Toggle 'Sort keys alphabetically' in settings to sort all object keys at every level. Sorting is useful for diff-friendly configs and version control.
Does the converter add quotes around strings?
No — by default, the converter emits 'plain' strings without quotes whenever the value would otherwise be ambiguous (e.g., true, false, null, numbers, or strings containing special characters). YAML parsers read both quoted and unquoted strings. Toggle 'Quote all strings' in settings to force quotes everywhere.
Can I convert a Kubernetes manifest JSON to YAML?
Yes. kubectl can output any resource as JSON; paste that into the converter and you'll get a clean YAML manifest ready to commit to a Git repo. The output uses 2-space indent, which is the Kubernetes convention.
What about multi-line strings?
JSON doesn't have a true multi-line string type, but YAML's 'literal block' style (using |) is supported. Long strings with embedded newlines are emitted as block scalars; single-line strings stay on one line.
Is my JSON data private?
Yes. All conversion happens in your browser using JavaScript. Your JSON is never transmitted to a server. The page uses HTTPS and runs no third-party tracking scripts during conversion.
Can I open the YAML in my editor?
Yes. The output is a standard .yaml or .yml file. It opens in any text editor (VS Code, Sublime, Vim, Notepad++) and in any IDE with YAML support. Most editors will syntax-highlight the file automatically.

Turn your JSON into YAML

Free, instant, and private — your JSON never leaves this tab.

Start Converting Read the FAQ