JSON ஃபார்மேட்டர்
JSON ஐ படிக்கக்கூடிய வடிவத்தில் ஃபார்மேட் செய்யுங்கள்.
API பதிலிலிருந்தோ அல்லது லாக் ஃபைலிலிருந்தோ கிடைக்கும் compact JSON-ஐ படிப்பது மிகவும் கடினமாக இருக்கும் — எல்லாமே ஒரே வரியில் indentation இல்லாமல் இருக்கும். ஒரு JSON formatter (இதை JSON prettifier அல்லது beautifier என்றும் அழைக்கிறார்கள்) சீரான indentation மற்றும் வரி பிரிப்புகளை சேர்த்து structure-ஐ ஒரே பார்வையில் தெரியும்படி செய்கிறது. இந்த tool எந்த valid JSON-ஐயும் 2 அல்லது 4 space indentation-உடன் format செய்து, nested objects, arrays, மற்றும் ஆழமான hierarchies-ஐ எளிதாக பார்க்கவும் debug செய்யவும் உதவுகிறது.
📋 இந்த கால்குலேட்டரை எப்படி பயன்படுத்துவது
Compact அல்லது minified JSON-ஐ input box-ல் paste செய்யவும். உங்களுக்கு விருப்பமான indentation-ஐ தேர்ந்தெடுக்கவும் — 2 spaces என்பது JavaScript மற்றும் JSON சமூகத்தின் standard, அதே சமயம் 4 spaces Python-ல் பொதுவாக பயன்படுத்தப்படுகிறது. உடனடியாக formatted output-ஐ காண "Format / Prettify JSON" என்பதை கிளிக் செய்யவும். முடிவை எடுக்க Copy பட்டனை பயன்படுத்தவும். Postman அல்லது curl போன்ற API tool-லிருந்து JSON-ஐ paste செய்தால், அது ஏற்கனவே ஓரளவு formatted ஆக இருக்கலாம்; இருந்தாலும் இந்த tool அதை சீரான indentation-க்கு normalize செய்யும்.
💡 முக்கிய தகவல்கள்
JSON formatting-க்கு JSON.stringify(parsedObject, null, indent) பயன்படுத்தப்படுகிறது — இது configurable indentation-உடன் objects-ஐ serialize செய்யும் built-in JavaScript function. Formatter முதலில் உங்கள் JSON-ஐ validate செய்யும் (invalid input-க்கு error காண்பிக்கும்), பிறகு நீங்கள் தேர்ந்தெடுத்த indent level-உடன் மீண்டும் serialize செய்யும். அதாவது, formatter input-ல் உள்ள முரண்பாடுகளையும் normalize செய்கிறது: அதிகப்படியான spaces-ஐ நீக்கும், mixed indentation-ஐ சரி செய்யும், மற்றும் deterministic output-ஐ தரும். பல code editors (VS Code, IntelliJ) built-in JSON formatters கொண்டவை; இந்த tool editor-க்கு வெளியே வேலை செய்யும்போது அல்லது ஒரு quick, one-off formatting task-க்கு பயனுள்ளதாக இருக்கும்.