Konverter YAML ke JSON

Butuh konversi sebaliknya?
JSON to YAML Converter

Input YAML

1

Output JSON

Masukkan data YAML untuk dikonversi menjadi JSON

Data hasil konversi akan muncul di sini

Cara mengonversi YAML ke JSON online – panduan langkah demi langkah

Gunakan konverter YAML→JSON ini untuk mengubah file konfigurasi, manifest Kubernetes, atau config CI/CD menjadi JSON untuk API dan tooling.

  1. Langkah 1 – Tempel atau unggah YAML

    • Tempel YAML ke editor kiri atau unggah file .yaml atau .yml.
    • Bekerja untuk Kubernetes, Docker Compose, workflow GitHub Actions, dan YAML umum.
    • YAML multi-dokumen (dipisahkan oleh ---) dikonversi menjadi array JSON.
  2. Langkah 2 – Tinjau hasil konversi

    • Output JSON muncul di kanan, menjaga struktur bersarang dan tipe data.
    • Komentar YAML dihapus (JSON tidak mendukung komentar).
    • Periksa array, object, dan nilai skalar sudah dikonversi dengan benar.
  3. Langkah 3 – Tangani kasus khusus

    • Anchor dan alias YAML mungkin perlu penyesuaian manual pada file yang kompleks.
    • Nilai boolean (true/false, yes/no) dinormalisasi menjadi boolean JSON.
    • Angka dan string dipertahankan dengan formatting JSON yang benar.
  4. Langkah 4 – Salin atau unduh JSON

    • Gunakan “Copy” untuk menyalin JSON ke clipboard.
    • Atau “Download” untuk menyimpan sebagai file .json.
    • Gunakan JSON di REST API, aplikasi frontend, atau alat apa pun yang membutuhkan input JSON.

Quick tips for YAML to JSON

  • Ensure indentation is consistent in your YAML; most conversion errors come from bad indent levels.
  • Multi-document YAML will be converted to a JSON array, which is ideal for lists of configs or resources.
  • After converting, run the JSON through the validator or formatter to catch any remaining structural issues.
Example: YAML to JSON
# YAML input
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  database_url: postgres://localhost/db
  debug: true
  ports:
    - 8080
    - 8081

// JSON output
{
  "apiVersion": "v1",
  "kind": "ConfigMap",
  "metadata": {
    "name": "app-config"
  },
  "data": {
    "database_url": "postgres://localhost/db",
    "debug": true,
    "ports": [8080, 8081]
  }
}

Related YAML & JSON tools

Convert between formats and work with configuration files using these complementary tools.

Pertanyaan yang Sering Diajukan

What YAML features are supported in the conversion?

The converter supports standard YAML features including scalars, sequences (arrays), mappings (objects), multi-line strings, and basic YAML syntax. Complex YAML features like anchors and references may have limited support.

How are YAML comments handled during conversion?

YAML comments are typically stripped during conversion to JSON since JSON doesn't support comments. The conversion focuses on the data structure rather than preserving comments.

Can I convert complex nested YAML structures?

Yes, the converter can handle deeply nested YAML structures with multiple levels of objects and arrays. The resulting JSON will maintain the same hierarchical structure.

What happens to YAML data types during conversion?

YAML data types are converted to their JSON equivalents: strings remain strings, numbers become JSON numbers, booleans stay as booleans, and null values are preserved. YAML's additional data types are converted to their closest JSON representation.

Konverter YAML ke JSON | JSONSwiss