Skip to content

Commit

Permalink
Create index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
technoid99 authored Mar 20, 2024
1 parent a739c6d commit aecd7b1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON Beautifier</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Beautify JSON</h1>
<input type="file" id="fileInput" accept=".json" />
<button onclick="beautifyJSON()">Beautify</button>
<pre id="jsonOutput"></pre>

<script>
function beautifyJSON() {
const fileInput = document.getElementById('fileInput');
const jsonOutput = document.getElementById('jsonOutput');
const file = fileInput.files[0];

if (file) {
const reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = function (evt) {
const json = JSON.parse(evt.target.result);
const beautifiedJSON = JSON.stringify(json, null, 4);
jsonOutput.textContent = beautifiedJSON;
}
reader.onerror = function (evt) {
alert("Error reading file");
}
} else {
alert("Please select a file");
}
}
</script>
</body>
</html>

0 comments on commit aecd7b1

Please sign in to comment.