Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Convert JSON to YAML

Convert JSON data to YAML format instantly. Handles nested objects, arrays, and all JSON types. 100% client-side.

Your files never leave your browser
JSON Input0 chars, 0 lines
YAML Output0 chars, 0 lines
Error:
    Ready·

    Paste your JSON, pick an indent size, and get valid YAML back — nested objects, arrays, nulls, all of it handled correctly. Strings only get quoted when YAML's spec actually demands it, so the output stays clean and readable. And everything runs in your browser. Nothing gets uploaded.

    How It Works

    Paste JSON
    ➔
    Parse & Transform
    ➔
    Get YAML

    The tool first validates your JSON to catch syntax errors — missing commas, trailing commas, unquoted keys, that sort of thing. Once the JSON parses cleanly, it walks the data tree recursively. Objects become YAML mappings with key: value pairs, arrays turn into dash-prefixed sequences, and primitives map directly to their YAML equivalents. Strings are left unquoted unless they contain characters that YAML would misinterpret (colons, hashes, brackets, etc.).

    Examples

    Simple API Response

    A typical user object from a REST endpoint — the kind you'd drop into a config file.

    INPUT
    { "name": "Alice", "age": 30, "active": true }
    OUTPUT
    name: Alice age: 30 active: true

    Docker Compose Service Definition

    Converting a JSON service config into something docker-compose.yml can actually use. Nested objects and arrays both show up here.

    INPUT
    { "web": { "image": "nginx:latest", "ports": ["80:80", "443:443"], "environment": { "NODE_ENV": "production", "LOG_LEVEL": "warn" } } }
    OUTPUT
    web: image: nginx:latest ports: - "80:80" - "443:443" environment: NODE_ENV: production LOG_LEVEL: warn

    Package.json Scripts Block

    Pulling script definitions out of a package.json for documentation or a CI config.

    INPUT
    { "scripts": { "dev": "next dev", "build": "next build", "test": "jest --coverage" } }
    OUTPUT
    scripts: dev: next dev build: next build test: jest --coverage

    Who Uses This

    👨‍💻 DevOps Engineers

    Converting JSON pipeline configs to YAML for Kubernetes, GitHub Actions, or Ansible.

    🌐 Backend Developers

    Turning API response samples into YAML fixtures for tests or documentation.

    📚 Technical Writers

    Reformatting JSON snippets as YAML for docs where readability matters more than machine parsing.

    🎓 Students

    Learning YAML syntax by seeing how familiar JSON structures map to it side by side.

    Common Mistakes

    Pasting invalid JSON

    Trailing commas after the last item in an object or array will break the parser. JavaScript allows them, but JSON does not. Remove that final comma before converting.

    Expecting comments to survive

    JSON doesn't support comments, period. If you're pasting JSON with // or /* */ comments, the parser will reject it. Strip them first or use a JSON5-aware tool.

    Confusing indentation with tab characters

    YAML is strict about spaces vs. tabs. This converter outputs spaces (2 or 4, your pick), but if you paste the result into a file that mixes tabs and spaces, YAML parsers will complain. Stick with spaces throughout.

    Technical Details

    Frequently Asked Questions

    Can I convert YAML back to JSON with this tool?

    Not here — this one goes JSON to YAML only. There is a separate YAML-to-JSON converter on the site that handles the reverse direction. Both work the same way: paste, click, copy.

    Does the converter preserve the order of keys?

    Yes. Keys appear in the YAML output in the exact same order as they are in your JSON. The tool does not sort or rearrange anything — what you put in is what comes out, just in a different format.

    What happens if my JSON has duplicate keys?

    JSON.parse keeps the last value when keys repeat in the same object. So if you have two "name" keys, only the second one makes it into the YAML. This is standard browser behavior, not a bug in the converter.

    Is there a file size limit?

    No hard limit. The conversion runs in your browser, so it depends on how much memory your device has. Files under 10 MB convert instantly. Larger files work too but might take a second or two.

    Why are some strings quoted in the YAML but not others?

    YAML has reserved characters and patterns. A string like "true" would be read as a boolean, and "3:00" looks like a sexagesimal number. The converter quotes strings only when leaving them bare would change their meaning. Plain text stays unquoted for cleaner output.

    Share: