A modern, interactive React-based tool for visualizing Swagger/OpenAPI specifications as hierarchical tree structures. This tool supports both standard Swagger format and custom categorized JSON structures for organized API documentation.
- Hierarchical Visualization: Clean tree structure showing API → Categories → Sub-categories → Endpoints
- Interactive Tree Navigation: Click to expand/collapse categories and sub-categories
- Multiple Format Support:
- Standard Swagger/OpenAPI JSON format
- Custom categorized JSON format with categories and sub-categories
- Visual Indicators:
- Color-coded HTTP methods (GET, POST, PUT, DELETE, etc.)
- Expandable/collapsible nodes with visual feedback
- Tooltips with endpoint details
- Zoom & Pan: Built-in controls for navigating large API structures
- Responsive Design: Clean, modern interface that works on different screen sizes
{
"openapi": "3.0.1",
"info": {
"title": "My API",
"version": "1.0.0"
},
"paths": {
"/users": {
"get": {
"tags": ["User Management"],
"summary": "Get all users"
}
}
}
}
{
"openapi": "3.0.1",
"info": {
"title": "My API",
"version": "1.0.0"
},
"paths": {
"categories": {
"Authentication Endpoints": {
"Login Endpoints": {
"/v1/api/Auth/LoginAdmin": {
"post": {
"tags": ["Auth"],
"summary": "Admin login"
}
}
}
}
}
}
}
-
Clone the repository
git clone <repository-url> cd swagger_visualizer
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
- Upload JSON File: Click the "Upload JSON" button and select your Swagger/OpenAPI JSON file
- Paste JSON: Copy and paste your JSON content directly into the textarea
- Load Sample: Use the "Load Sample" button to see the visualizer in action
- Expand/Collapse: Click on category or sub-category nodes (colored circles with +/- indicators)
- Zoom Controls: Use the zoom in/out buttons in the top-right corner
- Reset View: Click the reset button to return to the original view
- Pan: Click and drag to move around the visualization
- 🔵 API Root (Gray): The main API node
- 🔵 Categories (Blue): Primary groupings of endpoints
- 🟣 Sub-categories (Purple): Secondary groupings within categories
- 🟢 Endpoints (Color-coded by HTTP method):
- 🟢 GET (Green)
- 🔵 POST (Blue)
- 🟡 PUT (Yellow)
- 🔴 DELETE (Red)
swagger_visualizer/
├── src/
│ ├── components/
│ │ ├── HierarchyChart.tsx # Main visualization component
│ │ ├── chart.css # Styling for the chart
│ │ └── swagger - Copy.json # Sample categorized JSON file
│ ├── App.tsx # Main application component
│ └── main.tsx # Application entry point
├── package.json
└── README.md
- React 19: Modern React with hooks
- TypeScript: Type-safe development
- D3.js: Powerful data visualization library
- Vite: Fast build tool and dev server
- Lucide React: Beautiful icons
- Tailwind CSS: Utility-first CSS framework
To add support for additional node types, modify the following sections in HierarchyChart.tsx
:
- Node Type Detection (in
createTreeData
) - Visual Styling (in the D3 visualization code)
- Click Handlers (for expand/collapse functionality)
- Legend (to show the new node type)
The visualization uses a combination of:
- CSS classes in
chart.css
- Inline D3 styling
- Tailwind CSS utilities
- JSON Input → Parse and validate JSON structure
- Data Processing → Transform into hierarchical tree structure
- Tree Generation → Create D3 hierarchy with proper node types
- Visualization → Render interactive SVG with expand/collapse functionality
- User Interaction → Handle clicks, zoom, and pan operations
- JSON Not Loading: Ensure your JSON is valid and follows one of the supported formats
- Visualization Not Appearing: Check browser console for errors
- Performance Issues: Large APIs may require optimization - consider filtering or pagination
# Start development server
npm run dev
# Build for production
npm run build
# Run linter
npm run lint
# Preview production build
npm run preview
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is open source and available under the MIT License.
For questions, issues, or contributions, please open an issue on the GitHub repository.
Made with ❤️ for API developers and documentation enthusiasts