JSON إلى YAML

محوّل JSON إلى YAML يأخذ أي مستند JSON صالح ويحوّله إلى YAML منسّق بشكل صحيح. اختر مسافة بادئة 2 أو 4 أحرف وأسلوب اقتباس أدنى أو دائماً.

Built by Bob Article by Lace QA by Ben Shipped
IndentQuotes
YAML
YAML appears here as you type…

كيفية الاستخدام

  1. 1

    الصق JSON في صندوق الإدخال.

  2. 2

    اختر مسافة بادئة 2 أو 4 أحرف. 2 هي المعيار لـ Kubernetes و GitHub Actions.

  3. 3

    اختر أسلوب الاقتباس. 'الحد الأدنى' هو الأكثر قابلية للقراءة.

  4. 4

    انقر نسخ للحصول على YAML.

الأسئلة الشائعة

Ratings & Reviews

Rate this tool

Sign in to rate and review this tool.

Loading reviews…

What JSON to YAML Conversion Solves

You've got a JSON response from an API and need it as a Kubernetes manifest. You've exported your app config as JSON and need it readable enough to commit to git. You're handing infrastructure off to a teammate who reads YAML faster than JSON. The pattern is the same: JSON came out of a machine, but a human now needs to read or edit it. Converting to YAML makes the same data legible — comments where you need them, fewer brackets, indentation instead of nesting symbols.

The JSON to YAML Converter parses your JSON with the standard JavaScript parser, then serializes it with the js-yaml dumper using the conventions your YAML linter probably expects: 2-space indent, minimal quoting, no unnecessary block markers. The output drops into Helm charts, GitHub Actions, Docker Compose, or any other YAML-eating system without further cleanup.

How the Microapp JSON to YAML Converter Works

Paste any JSON into the input box. The YAML output appears as you type. Pick 2 or 4-space indent (2 matches Kubernetes/GitHub Actions/Docker Compose; 4 matches some Ansible conventions). Pick quote style: minimal (the default — only quotes strings when YAML would misparse them) or always (forces double quotes around every string for maximum safety).

The conversion happens entirely in your browser. The js-yaml library runs as JavaScript locally; nothing is uploaded, logged, or stored. Your JSON — which often contains secrets, API responses, internal IDs — never leaves your machine.

Worked example. Paste this API response:
{"name":"api","port":8080,"env":{"NODE_ENV":"production"}}
Output (with 2-space indent, minimal quoting):
name: api
port: 8080
env:
  NODE_ENV: production

Drop straight into a Kubernetes ConfigMap or a Docker Compose environment block.

Why Convert JSON to YAML in the First Place

Configs that humans edit. JSON's strictness — quoted keys, no comments, mandatory commas — makes it brutal to hand-edit. Miss one comma in a deeply nested object and the whole thing rejects. YAML's whitespace-based structure forgives more and reads cleaner.

Tools that demand YAML. Kubernetes, Helm, Argo CD, Ansible, GitHub Actions, GitLab CI, Docker Compose, Cloud Build, Tekton — the entire modern devops stack reads YAML. Converting from JSON is the bridge between "what your app produced" and "what your deployment pipeline accepts."

Documentation. A YAML config block in your README is more scannable than a JSON one. Keys aren't quoted, comments explain the non-obvious values, and the indentation visually communicates the hierarchy.

Quote Style: When Each Matters

Minimal quoting (the default): the dumper omits quotes whenever YAML's parser will unambiguously parse the value as a string. Cleaner, more readable. Risk: a string that looks like a YAML number, boolean, or special value (yes, no, on, off, null, ~, 1.0, 2.10) needs quotes — the dumper adds them automatically when needed.

Always quoting: every string gets double-quoted, no exceptions. Safer for round-trips between systems where the YAML parsers might differ. Verbose but unambiguous. Pick this when you're producing YAML for a strict consumer or when your strings frequently look like other types.

Common Conversion Pitfalls

The version-string problem. JSON's "version": "2.10" is unambiguous — a string. In YAML, version: 2.10 is the number 2.1 (trailing zero dropped). With minimal quoting, the dumper detects the ambiguity and quotes it as "2.10"; with no quoting (a worse default), you'd lose the trailing zero.

The Norway problem. JSON's "country": "NO" needs to stay quoted in YAML output, because country: NO would parse as boolean false in YAML 1.1. Minimal quoting handles this; bare conversion does not.

Number precision. JSON numbers are doubles, no special handling for big integers. If your JSON has "id": 9007199254740993 (above Number.MAX_SAFE_INTEGER), it lost precision before this tool saw it. Convert big integers to strings in the source.

Comments lost from a previous round trip. If your JSON came from converting YAML earlier, the comments in the original YAML were stripped (JSON has no comment syntax). Converting back to YAML doesn't restore them — they're gone. Keep the original YAML if you need the comments.

What's Different from a Naive JSON.stringify + Hand Translation

Hand-translating JSON to YAML works for tiny objects but breaks for anything nested. Indentation must be exact (mixing tabs and spaces fails). Strings need conditional quoting. Multi-line strings need block-scalar syntax (| or >). The dumper handles all of this; you don't have to remember the rules.

Related Tools

For the reverse direction (YAML to JSON), use the YAML to JSON Converter. To pretty-print or validate JSON without converting, the JSON Formatter is the right tool. To convert JSON to flat tabular data, see JSON to CSV or its inverse CSV to JSON. To compare two JSON documents structurally, use JSON Diff.