JsonToTable is a minimalist web application that converts JSON data into clean, readable HTML tables with the ability to export as PDF. The application features a dark/light theme toggle, resizable interface, and responsive design for both mobile and desktop usage.
- Parses user input as JSON with try/catch error handling
- Validates JSON structure before processing
- Displays human-readable error messages for invalid JSON
- Supports all JSON data types: objects, arrays, strings, numbers, booleans, and null
- Recursively processes JSON structure to generate nested HTML tables
- Differentiates between objects, arrays, and primitive values
- Handles nested objects with subtables
- Formats arrays with left-border styling
- Type-specific styling for different data types (numbers, booleans, null, strings)
- Clean border system with hover effects
- Converts HTML tables to PDF using html2canvas and jsPDF
- Customizable export settings:
- Page size (A4, Letter, Legal, A3)
- Orientation (Portrait, Landscape)
- File name customization
- Quality settings (High, Medium, Low)
- Adds header with title and date to PDF exports
- Optimized for print with forced light theme
- Dark/light theme toggle with persistent user preference
- Complete CSS variable-based theming system
- Smooth transitions between themes
- Theme-specific styling for all UI elements
- Print-optimized light theme for PDF exports
- Adapts to mobile and desktop viewports
- Single column layout on mobile, two-column layout on desktop
- Touch-friendly buttons and controls (minimum 44px touch targets)
- Font size adjustments for different screen sizes
- Horizontally resizable panels using mouse/touch drag
- Minimum and maximum width constraints
- Visual feedback during resize operations
- Resize handle with hover effects
- Mobile-responsive (hidden on smaller screens)
-
HTML Structure (index.html)
- Semantic HTML5 markup
- Organized container structure
- Input section with textarea and controls
- Output section for rendered tables
- PDF settings panel with export options
- Theme toggle button
-
CSS Styling (styles.css)
- CSS variables for theming
- Mobile-first responsive design
- Minimalist aesthetic with essential styling only
- Three core spacing units (8px, 16px, 32px)
- Three typography sizes (32px, 16px, 14px)
- Clean table borders with hover states
- Print media queries for PDF export
-
JavaScript Modules
- app.js: Core application logic, event handlers, theme toggle, resize functionality
- tableGenerator.js: JSON parsing and HTML table generation
- pdfExporter.js: PDF generation using html2canvas and jsPDF
- User inputs JSON in the textarea
- System parses JSON using
JSON.parse() - Recursive function processes each JSON level:
- Objects → HTML tables with key-value rows
- Arrays → Vertically stacked items with left border
- Nested objects → Subtables with proper hierarchy
- Primitive values → Styled based on data type
- Generated HTML injected into output container
- User configures export settings
- System creates hidden container with optimized table styling
- html2canvas converts the table to canvas
- jsPDF creates PDF document based on canvas
- Document saved with user-specified filename
- CSS variables define color scheme for both themes
- Theme preference stored in localStorage
data-themeattribute on HTML controls active theme- Toggle button switches between themes
- System respects user's preferred color scheme on first visit
- Resize handle positioned between input and output sections
- Mouse/touch down event initializes resize operation
- Mouse/touch move calculates new width based on pointer position
- Width constraints prevent breaking layout
- Mouse/touch up finalizes resize operation
- Modern evergreen browsers (Chrome, Firefox, Safari, Edge)
- CSS variables with fallbacks for older browsers
- Touch events for mobile devices
- Responsive design for all screen sizes
- Minimal DOM operations during table generation
- Throttled resize events for smooth performance
- Optimized PDF rendering with quality settings
- CSS transitions only on necessary properties
- Proper cleanup of event listeners
- Semantic HTML structure
- Keyboard navigable interface
- Proper color contrast in both themes
- Minimum touch target sizes (44px)
- Screen reader friendly markup
- Alt text for all images
- JSON schema validation
- Table filtering and sorting
- CSV export option
- JSON path navigation
- Collapsible nested objects
- Syntax highlighting in JSON input
- Custom theme editor
- Table of contents for complex JSON