</>
DevToolHub

YAML to JSON Converter

Paste YAML and get formatted JSON output, or switch direction to convert JSON back to YAML. Supports nested objects, arrays, multiline strings, and inline syntax.

YAML Input
JSON Output
// JSON Output will appear here

How It Works

The converter parses your YAML input by analyzing indentation levels to reconstruct the document hierarchy. Each indented block becomes a nested object, lines starting with - become array elements, and scalar values are automatically typed as strings, numbers, booleans, or null. The reverse direction serializes JSON into clean, human-readable YAML with proper indentation.

Everything runs client-side in your browser. No data leaves your machine, so config files with database credentials or API keys stay private.

YAML vs JSON Comparison

FeatureYAMLJSON
ReadabilityDesigned for humans, indentation-basedVerbose with braces and quotes
CommentsSupported with #Not supported in spec
Data typesStrings, numbers, booleans, null, dates, binaryStrings, numbers, booleans, null, arrays, objects
Multiline stringsNative support with | and > operatorsRequires escape characters (\n)
File sizeSmaller (no quotes or braces)Larger due to syntax overhead
Parsing speedSlower (indentation parsing)Faster (well-defined grammar)
Common useConfig files, Docker Compose, Kubernetes, CI/CDAPIs, data exchange, package manifests
Anchors/aliasesSupported (& and *)Not supported

YAML Syntax Quick Reference

SyntaxMeaningExample
key: valueKey-value pairname: Alice
nested:Nested object (indent 2 spaces)server: port: 8080
- itemArray element- redis - postgres
[a, b, c]Inline arraytags: [dev, staging]
|Multiline string (preserves newlines)description: | Line 1 Line 2
>Folded string (joins lines with spaces)summary: > Long text on two lines
# commentComment (ignored by parser)# database config
~ or nullNull valueoptional_field: ~

FAQ

Can I convert JSON back to YAML with this tool?

Yes. Click the direction toggle button at the top to switch between YAML-to-JSON and JSON-to-YAML modes. The converter handles both directions and produces clean, properly indented output in either format.

Does the converter preserve comments from YAML?

No. JSON has no comment syntax, so comments are stripped during conversion. This is a limitation of the JSON specification itself, not this tool. If you need to preserve comments, keep your original YAML file alongside the generated JSON.

How does the tool handle YAML multiline strings?

The pipe operator (|) preserves line breaks and the greater-than operator (>) folds lines into a single string separated by spaces. Both are converted to standard JSON string values with appropriate escaping.

What YAML features are not supported?

This converter handles the most common YAML patterns: key-value pairs, nested objects, arrays, inline syntax, multiline strings, and all standard scalar types. Advanced features like anchors (&), aliases (*), and custom tags are not supported. For documents using these features, use a full-spec YAML parser like js-yaml.

Working with TypeScript? Convert JSON to TypeScript interfaces or generate Zod schemas from JSON.