JSON, YAML and XML converter
Validate, pretty-print or convert between JSON, YAML and XML for their shared subset. External entities and custom tags are rejected.
Process locally
Files stay in this browser session. Closing or clearing releases them.
Add text
Type or paste the text to process
Adjust settings
Optional: Input format, Output format, Indent and more
Run
Processes in this browser; cancel at any time
About this tool
Convert data between JSON, YAML and XML, or validate and pretty-print one of them. Use it to turn a JSON API response into a YAML config, read an XML document as JSON, or check that a YAML file parses before you deploy it.
Conversion works on the data the three formats share: objects, lists, text, numbers, true/false and null, so comments are not carried over. For safety, XML DOCTYPE and entity declarations and custom YAML tags are rejected. Up to 1 MB is processed in your browser and is not uploaded.
How to use it
- Paste JSON, YAML or XML, or select “Use example” to load a small JSON object.
- Pick the “Input format” and the “Output format”. Choose the same format for both to validate and pretty-print.
- Set the “Indent” in spaces, from 0 to 8 (2 by default); 0 puts JSON and XML on one line. Tick “Sort keys” to sort the keys of every object by character code.
- Select “Run”, then preview the result and download it as converted.json, converted.yaml or converted.xml.
Formats and limits
- Input
- Text
- Output
- JSON, YAML, XML
- Size limit
- 1 MB
- Settings
- Input format (JSON, YAML, XML); Output format (JSON, YAML, XML); Indent; Sort keys
- Privacy
- Files stay in the current browser session. No file bytes are uploaded.
- Price
- Free, no sign-up
Common questions
How is XML mapped to JSON or YAML?
The root element becomes the top-level key, attributes become keys starting with @, and text next to child elements goes under #text. Repeated child elements become a list. XML has no data types, so every value comes out as text, such as “30” rather than 30.
Why is the XML output wrapped in <root>?
XML needs exactly one root element. When the data has a single top-level key, that key becomes the root; otherwise everything is wrapped in <root>. Keys that are not valid XML names, such as ones with spaces or starting with a digit, and lists nested directly in lists cannot be converted to XML.
Why was my YAML rejected?
Custom tags such as !!python/object, duplicate keys in one mapping and files with several documents separated by --- are not accepted, so convert one document per run. Merge keys (<<) are kept as ordinary keys rather than merged.
Are long numbers and comments kept?
Numbers are read as JavaScript numbers, so integers above 9007199254740991 lose precision; keep long IDs as strings. Comments in YAML and XML are dropped, because only the data is converted.
Why are DOCTYPE and entities refused?
XML DOCTYPE and entity declarations can expand or fetch content, so they are rejected. Only the five predefined entities such as & and numeric references such as © are decoded, and processing instructions other than the XML declaration are refused too.
Related tools
Code formatter
Format or minify HTML, CSS, SCSS, Less, JavaScript, TypeScript, JSON, Markdown, YAML, XML, SQL, C, C++, C#, Java, PHP, Python and nginx configuration.
JSON format and validate
Format, minify or sort JSON, repair common mistakes, or escape it as a string. Errors show the line and column, and large numbers keep every digit.
Key-value pairs to code
Turn key=value or key: value lines into JSON, YAML, .properties, .env, TypeScript, Python, PHP, Java, C#, Go, HTML options or SQL.
Convert dates and time zones
Convert one date-time per line between ISO 8601, Unix time and local time in named time zones. Daylight-saving gaps and repeats are reported.
Lunar calendar converter
Convert Gregorian dates to the Chinese lunar calendar with stem-branch year, zodiac, solar terms and festivals, or lunar dates (leap months marked 闰) back to Gregorian, one per line.
JSON to code types
Generate TypeScript interfaces, C# classes, Java records, Go structs, Rust serde structs or Python dataclasses from sample JSON. Fields missing from some samples become optional.