JSON Viewer & Tree Formatter
Features & Implementation Details
Recursive Tree Generation: The
createTreefunction calls itself whenever it encounters a nested object or array. This allows the tool to handle JSON of any depth.Collapsible Nodes: Clicking the
[-]or[+]signs toggles a CSS class that hides or shows nested lists, making it easy to navigate massive data structures.Syntax Highlighting: Different colors are assigned to keys, strings, numbers, and booleans using specific CSS classes to improve readability.
Error Handling: If the user pastes invalid code, the tool catches the error and displays a helpful message instead of crashing.
AdSense Readiness: * Header Ad: High visibility above the main tool.
Footer Ad: Captures revenue as users finish their task.
Responsive: Uses a CSS Grid that stacks the input and output vertically on smaller screens.
How to Deploy
Save the file as
json-viewer.html.Replace
ca-pub-YOUR_CLIENT_IDwith your actual AdSense Publisher ID.If you want to change the theme, modify the CSS variables in the
:rootsection.