Paste JSON or YAML: the other side updates as you type. 100 % local processing in your browser: no data is sent to a server.
1
1
JSON and YAML are two text formats used to describe structured data: objects (key / value pairs), lists, strings, numbers and booleans. JSON relies on braces, brackets and quotes, whereas YAML uses indentation and is designed to be easy to read and write by hand.
This tool converts JSON to YAML, or YAML to JSON, as you type. The area you edit is the source and the other one shows the result. If the source is invalid, the parser error is displayed and the previous result stays in place.
{"name":"DTK","version":"1.0","tools":[{"id":1,"label":"JSON Formatter"}],"active":true}name: DTK
version: "1.0"
tools:
- id: 1
label: JSON Formatter
active: true# Server configuration server: host: localhost port: 8080 debug: false
{
"server": {
"host": "localhost",
"port": 8080,
"debug": false
}
} In the first example, "1.0" stays quoted in YAML: without quotes, it would be read as the number 1 . In the second example, the comment disappears, because JSON has no comment syntax.
YAML is permissive in appearance, but its rules on indentation and special characters are strict. The following mistakes are the most frequent.
server: host: localhost
server: host: localhost
name:DTK
name: DTK
message: Error: file not found
message: "Error: file not found"
version: 1.10
version: "1.10"
name:DTK is read as a single string, and 1.10 as the number 1.1 . Converting the YAML to JSON is a quick way to check how it is really interpreted. true and false are booleans: values such as yes , no or on are kept as strings. & ) and aliases ( * ) are resolved: the referenced value is copied at each place where it is used. --- cannot be converted to a single JSON document and triggers an error. .inf and .nan do not exist in JSON and are converted to null . base: &port 8080
api: *port
→ {"base": 8080, "api": 8080}no is a boolean. Lists of country codes therefore turned Norway ( NO ) into false : this is known as the "Norway problem", and one of the reasons why YAML 1.2 restricted booleans to true and false . .yaml file extension, although .yml remains very common. --- separators. yes , no , on , off ) and numbers written with a leading zero, which YAML 1.1 reads as octal. Check the JSON result if your file relies on these values.