Skip to content

JSON / YAML Formatter

Formatage, validation et conversion JSON/YAML.

Reference

JSON

{
  "string": "Hello",
  "number": 42,
  "float": 3.14,
  "boolean": true,
  "null": null,
  "array": [1, 2, 3],
  "object": {
    "nested": "value"
  }
}

YAML

string: Hello
number: 42
float: 3.14
boolean: true
null_value: null
array:
  - 1
  - 2
  - 3
object:
  nested: value

# Syntaxe alternative pour arrays
inline_array: [1, 2, 3]

# Multi-ligne
description: |
  Premiere ligne
  Deuxieme ligne

# Multi-ligne sans newlines finaux
compact: >
  Cette phrase sera
  sur une seule ligne

Outils CLI

# Valider JSON
cat file.json | jq .

# Formater JSON
cat file.json | jq '.' > formatted.json

# Minifier JSON
cat file.json | jq -c '.'

# YAML vers JSON (avec yq)
yq -o=json file.yaml

# JSON vers YAML (avec yq)
yq -P file.json

# Valider YAML
python -c "import yaml; yaml.safe_load(open('file.yaml'))"