Explanation
HTML Structure:
<textarea>: Input area for users to paste JSON text.
Button: Triggers the formatJSON function to parse and format JSON.
<div id="jsonOutput">: Displays the formatted JSON with collapsible structure.
CSS Styling:
Container & Colors: Gradient background and blue-themed button styling.
Button Hover Effect: Changes colour on hover.
Responsive: Adjusts to smaller screens with dynamic font sizes.
JavaScript Function:
formatJSON:
Parse JSON: If successful, it uses the json-viewer-js library to format JSON with a structured view.
Error Handling: Displays an error message if the JSON is invalid.
How to Use
Paste JSON: Copy and paste a JSON object into the textarea. For example: