A powerful web tool that converts API documentation pages into clean, organized Markdown format.
- One-Click Conversion: Simply paste a URL and convert any public API documentation to Markdown
- Live Preview: See the converted Markdown in real-time with both raw and rendered views
- Syntax Highlighting: Code blocks are properly formatted with language-specific syntax highlighting
- Smart Extraction: Automatically identifies and extracts relevant content from documentation pages
- Table Support: Preserves table formatting in the converted Markdown
- Download Option: Export your converted documentation as a Markdown file
App.tsx
: Main application component with URL input and conversion controlsPreview.tsx
: Handles both raw Markdown and rendered preview with syntax highlightingProgressBar.tsx
: Visual feedback for conversion progress
useDocumentConverter.ts
: Core conversion logic with the following features:- CORS-friendly document fetching using a proxy service
- Smart content extraction with prioritized selectors
- Custom HTML to Markdown conversion rules
- Table structure preservation
- Code block language detection
- Link path normalization
- Error handling and progress tracking
-
Fetching Content
- Uses axios with CORS proxy (api.allorigins.win)
- Handles various HTTP errors (404, 403, 429)
- 10-second timeout with automatic retry
-
Content Extraction
- Removes non-essential elements (scripts, styles, nav, etc.)
- Uses prioritized content selectors:
const contentSelectors = [ 'main', 'article', '.content', '.documentation', '.docs-content', '.api-content', '#main-content', '.markdown-body', '.readme', '.api-docs', '[role="main"]', '[role="article"]' ]
- Falls back to largest content block if no matches
-
HTML Cleaning
- Removes empty elements
- Preserves essential attributes (class, href, src, alt, title)
- Normalizes table structures (adds tbody, thead)
- Escapes code blocks
-
Markdown Conversion
- Custom TurndownService rules for:
- Code blocks with language detection
- Tables with alignment support
- Links with path normalization
- Definition lists
- Post-processing for clean formatting
- Custom TurndownService rules for:
Uses PrismLight for efficient syntax highlighting with support for:
- TypeScript/JavaScript
- Bash/Shell
- JSON
- Markdown
- GraphQL
- YAML
- HTTP
Comprehensive error handling for:
- Invalid URLs
- Network timeouts
- Access forbidden (403)
- Not found (404)
- Rate limiting (429)
- Empty or insufficient content
- Malformed HTML
src/
├── components/
│ ├── Preview.tsx # Markdown preview component
│ └── ProgressBar.tsx # Progress indicator
├── hooks/
│ └── useDocumentConverter.ts # Core conversion logic
└── types.ts # TypeScript type definitions
- Clone and install dependencies:
git clone https://github.com/yashrajnayak/apidocs2markdown.git
cd apidocs2markdown
npm install
- Start development server:
npm run dev
- Run linting:
npm run lint
The project uses:
- Vite for fast development and optimized builds
- TypeScript for type safety
- ESLint with React Hooks plugin
- Tailwind CSS with Typography plugin
- React 18 with Strict Mode
Production builds include:
- Tree-shaking for minimal bundle size
- Automatic code splitting
- CSS minification
- Source maps generation
Build command:
npm run build
Automated GitHub Actions workflow:
- Triggered on push to main branch
- Builds production assets
- Deploys to GitHub Pages
- Configures SPA routing
- Enter the URL of any public API documentation page
- The tool fetches the content while preserving the structure
- Smart content extraction removes unnecessary elements like navigation and ads
- Converts the cleaned HTML to well-formatted Markdown
- Provides both raw Markdown and rendered preview
- Download the result as a Markdown file
- React
- TypeScript
- Vite
- TailwindCSS
- cheerio (for HTML parsing)
- turndown (for HTML to Markdown conversion)
- React Markdown (for preview rendering)
Contributions are welcome! Please read our contributing guidelines before submitting a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
- Use TypeScript for all new code
- Follow the existing code style
- Add JSDoc comments for public APIs
- Keep components focused and composable
This project is open source and available under the MIT License.
Created by Yashraj Nayak