Panduan JSON Beautifier 2026: Memformat dan Pretty Print JSON
Panduan lengkap JSON beautifier. Pelajari cara memformat, me-minify, dan me-pretty print JSON menggunakan alat online, baris perintah, dan kode.
Big JSON Team
• Technical WriterExpert in JSON data manipulation, API development, and web technologies. Passionate about creating tools that make developers' lives easier.
Apa itu JSON Beautifier?
JSON beautifier (juga disebut pemformat atau pretty printer) mengubah JSON yang ringkas menjadi format yang mudah dibaca dan memiliki indentasi.
Sebelum (Diminimalkan/Minified)
{"users":[{"name":"Alice","age":30},{"name":"Bob","age":25}]}
Sesudah (Dipercantik/Beautified)
{
"users": [
{
"name": "Alice",
"age": 30
},
{
"name": "Bob",
"age": 25
}
]
}
Mengapa Mempercantik (Beautify) JSON?
Beautifier Online
Big JSON Viewer
Menangani file hingga 100MB+
JSONLint
Validator klasik dengan fitur pemformatan.
Alat Baris Perintah (Command Line Tools)
jq
# Instalasi
brew install jq # Mac
apt install jq # Linux
# Mempercantik (Beautify)
jq '.' input.json > output.json
# Indentasi kustom
jq --indent 4 '.' input.json
# Urutkan kunci
jq -S '.' input.json
Python
# Modul bawaan
python -m json.tool input.json
# Indentasi kustom
python -c "import json; print(json.dumps(json.load(open('input.json')), indent=4))"
Pemformatan Editor Kode
VS Code
- Pintasan: Shift+Alt+F (Windows) atau Shift+Option+F (Mac)
- Perintah: Ctrl+Shift+P → "Format Document"
- Format otomatis saat simpan: Aktifkan di pengaturan (settings)
Pempercantikan Programatik
JavaScript
const ugly = '{"name":"John","age":30}';
const pretty = JSON.stringify(JSON.parse(ugly), null, 2);
console.log(pretty);
// Indentasi kustom (4 spasi)
JSON.stringify(obj, null, 4);
// Tab alih-alih spasi
JSON.stringify(obj, null, '\t');
Python
import json
ugly = '{"name":"John","age":30}'
data = json.loads(ugly)
pretty = json.dumps(data, indent=2)
print(pretty)
# Urutkan kunci
json.dumps(data, indent=2, sort_keys=True)
Minifikasi JSON
Kebalikannya - menghapus spasi kosong untuk mengurangi ukuran file:
// JavaScript
const minified = JSON.stringify(obj);
// jq
jq -c '.' input.json
Perbandingan Alat
| Alat | Kecepatan | File Besar | Validasi | Gratis |
|------|-------|-------------|------------|------|
| Big JSON Viewer | Cepat | ✅ | ✅ | ✅ |
| jq | Sangat Cepat | ✅ | ❌ | ✅ |
| VS Code | Cepat | Sedang | ✅ | ✅ |
| Python | Sedang | Sedang | ❌ | ✅ |
Praktik Terbaik
Opsi Pemformatan
Gaya Indentasi
- 2 spasi: Standar untuk pengembangan web
- 4 spasi: Umum dalam proyek Python
- Tab: Kurang umum, ukuran file lebih besar
Pengurutan Kunci
Kunci yang diurutkan secara alfabetis membuat diff lebih jelas:
{
"age": 30,
"email": "alice@example.com",
"name": "Alice"
}
Kesimpulan
Untuk pemformatan cepat, gunakan Big JSON Viewer atau jq. Untuk pengeditan rutin, konfigurasikan editor Anda agar memformat secara otomatis saat menyimpan!
Artikel Terkait
Cara Memformat JSON: Panduan Pretty Print dan Beautify 2026
Pelajari cara memformat dan mempercantik JSON menggunakan alat baris perintah, editor kode, pemformat online, dan bahasa pemrograman. Panduan lengkap dengan contoh.
Cara Membuka File JSON: Panduan Lengkap untuk Semua Platform
Pelajari cara membuka dan melihat file JSON di Windows, Mac, dan Linux. Mencakup editor teks, alat online, dan penampil JSON khusus.
Alat Online JSON Terbaik 2026: Viewer, Validator, dan Formatter
Panduan komprehensif tentang alat online JSON terbaik. Bandingkan viewer, validator, formatter, dan konverter untuk bekerja dengan data JSON.