JSONYAMify

Home / Blog / 10 Kesalahan Umum JSON

10 Kesalahan Umum Saat Menulis JSON dan Cara Memperbaikinya

Oleh Andi Putra Ogie · Update: Juni 2026 · 7 menit baca

  1. Trailing comma. {"a":1, "b":2,} — koma setelah elemen terakhir tidak valid. Hapus koma sebelum kurung penutup.
  2. Single quote. {'a': 1} — JSON wajib pakai tanda kutip dua. Ganti semua ' jadi ".
  3. Key tanpa kutip. {a: 1} — beda dengan object literal JavaScript, key JSON harus selalu diapit "a".
  4. Comment di dalam JSON. // catatan — JSON murni tidak mendukung komentar sama sekali, hapus atau pindahkan ke dokumentasi terpisah.
  5. NaN, undefined, atau function. Nilai-nilai ini valid di JavaScript tapi tidak valid di JSON. Gunakan null sebagai gantinya.
  6. Encoding karakter spesial yang salah. Karakter seperti tab, newline, atau tanda kutip di dalam string harus di-escape: \n, \t, \".
  7. Duplicate key. {"a":1, "a":2} — secara teknis bisa diparse oleh sebagian parser (akan ambil nilai terakhir), tapi sangat berisiko ambigu dan sebaiknya dihindari.
  8. Angka dengan leading zero. 0123 tidak valid sebagai number JSON. Kalau memang format seperti kode pos/kode area, simpan sebagai string: "0123".
  9. Bracket/brace tidak seimbang. Kurang satu } atau ] sering jadi penyebab error "Unexpected end of JSON input" — biasanya terjadi pada struktur sangat nested.
  10. BOM (Byte Order Mark) tersembunyi. File JSON yang disimpan dengan encoding tertentu kadang punya karakter BOM tak terlihat di awal file yang membuat parser gagal — simpan ulang sebagai UTF-8 tanpa BOM.
💡 Daripada mencari error satu-satu secara manual, paste JSON kamu ke JSONYAMify — tool akan menunjukkan baris bermasalah secara otomatis sekaligus menawarkan auto-fix untuk kesalahan format yang umum.
🔧 Validasi JSON Kamu Sekarang

10 Common JSON Mistakes and How to Fix Them

By Andi Putra Ogie · Updated: June 2026 · 7 min read

  1. Trailing comma. {"a":1, "b":2,} — a comma after the last element is invalid. Remove it before the closing bracket.
  2. Single quotes. {'a': 1} — JSON requires double quotes. Replace every ' with ".
  3. Unquoted keys. {a: 1} — unlike JavaScript object literals, JSON keys must always be wrapped in "a".
  4. Comments inside JSON. // note — pure JSON has zero support for comments; remove them or move them to separate documentation.
  5. NaN, undefined, or functions. These are valid in JavaScript but invalid in JSON. Use null instead.
  6. Incorrect special character encoding. Characters like tabs, newlines, or quotes inside strings must be escaped: \n, \t, \".
  7. Duplicate keys. {"a":1, "a":2} — technically some parsers accept this (keeping the last value), but it's highly ambiguous and should be avoided.
  8. Numbers with leading zeros. 0123 is not a valid JSON number. If it's a format like a zip/area code, store it as a string instead: "0123".
  9. Unbalanced brackets/braces. A missing } or ] is a common cause of "Unexpected end of JSON input" errors, especially in deeply nested structures.
  10. Hidden BOM (Byte Order Mark). JSON files saved with certain encodings can carry an invisible BOM character at the start that breaks parsers — re-save as UTF-8 without BOM.
💡 Instead of hunting for errors manually, paste your JSON into JSONYAMify — it automatically points out the problem line and offers auto-fixes for common formatting mistakes.
🔧 Validate Your JSON Now