Code Highlight API - Syntax Highlight to HTML
Tokenizes the input code (keywords, strings, comments, numbers, identifiers, punctuation) and wraps each token in a colored span. Returns a self-contained <pre><code> block with inline styles plus the language label. Supports JavaScript, Python, SQL, and other BPE-friendly languages.
Code examples
curl -X POST https://api.botoi.com/v1/code/highlight \
-H "Content-Type: application/json" \
-d '{"code":"def hello(name):\n return f\"Hi {name}!\"","language":"python","theme":"light"}'When to use this API
Render code on a static site without client-side JS
Call this endpoint at build time for each code block and inline the returned HTML. Your site renders highlighted code on first paint with zero JS bundle overhead for Prism or Shiki.
Generate screenshot-ready code snippets
Combine with /v1/screenshot/capture: highlight the code, pass the HTML through the screenshot endpoint, and get a social-shareable image of your code snippet.
Email-friendly code in transactional messages
Email clients strip <script> tags but allow inline styles. The self-contained output from this endpoint renders as-is in Gmail, Outlook, and Apple Mail with no extra processing.
Frequently asked questions
Which themes are available?
Which languages have accurate tokenization?
Is the HTML safe to embed directly?
Can I pass my own CSS classes?
What is the size limit?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.