|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <meta name="description" content="Online JSON Formatter / Beautifier and JSON Validator will format JSON data, and helps to validate, convert JSON to XML, JSON to CSV. Save and Share JSON"> |
| 7 | + <meta name="author" content="Ankit Verma"> |
| 8 | + <meta name="keywords" content="json formatter, json beautifier, json validator, online json formatter, json formatter online, json beautify,beautify json, ,format json, jsonlint, JSON Checker, JSON Cleaner, json converter, json format, json online format, format json online"> |
| 9 | + <meta property="og:title" content="Best JSON Formatter and JSON Validator: Online JSON Formatter" /> |
| 10 | + <meta property="og:description" content="Online JSON Formatter / Beautifier and JSON Validator will format JSON data, and helps to validate, convert JSON to XML, JSON to CSV. Save and Share JSON" /> |
| 11 | + <meta property="og:image" content="https://avcodewizard.github.io/jsonformatter/jsonformatter.png" /> |
| 12 | + <meta property="og:url" content="https://avcodewizard.github.io/jsonformatter" /> |
| 13 | + <meta property="og:type" content="website" /> |
| 14 | + <link rel="canonical" href="https://avcodewizard.github.io/jsonformatter" /> |
| 15 | + <!-- <link rel="shortcut icon" type="image/png" href="/img/favicon.png" /> --> |
| 16 | + <title>Best JSON Formatter and JSON Validator: Online JSON Formatter | Ankit Verma</title> |
| 17 | +</head> |
| 18 | + |
| 19 | +<body> |
| 20 | + <h1>JSON Formatter</h1> |
| 21 | + <textarea id="jsonInput" placeholder="Enter JSON here..." rows="10" cols="50"></textarea><br> |
| 22 | + <button onclick="formatJson()">Format JSON</button><br><br> |
| 23 | + <pre id="formattedJsonOutput"></pre> |
| 24 | + |
| 25 | + <script> |
| 26 | + function formatJson() { |
| 27 | + const jsonInput = document.getElementById('jsonInput').value; |
| 28 | + try { |
| 29 | + // Parse the input JSON |
| 30 | + const parsedJson = JSON.parse(jsonInput); |
| 31 | + // Format JSON with pretty print |
| 32 | + const formattedJson = JSON.stringify(parsedJson, null, 4); |
| 33 | + document.getElementById('formattedJsonOutput').textContent = formattedJson; |
| 34 | + } catch (error) { |
| 35 | + document.getElementById('formattedJsonOutput').textContent = 'Invalid JSON: ' + error.message; |
| 36 | + } |
| 37 | + } |
| 38 | + </script> |
| 39 | +</body> |
| 40 | +</html> |
0 commit comments