\render{equation-to-image}
Convert any LaTeX math expression into a high-quality PNG, SVG, PDF, or MathML output. This guide covers the FormaTeX online tool and API, output format trade-offs, advanced rendering options, web embedding techniques, and a head-to-head comparison with CodeCogs, QuickLaTeX, KaTeX, and MathJax.
LaTeX produces the gold standard in mathematical typesetting, but the output is locked inside PDF files compiled by a TeX engine. Most of the places where you actually need to show math — slide decks, websites, chat messages, Word documents, README files — cannot interpret LaTeX source code. Rendering your equation to an image bridges this gap: you get LaTeX-quality typography in a format that works everywhere.
The alternative is to approximate the rendering in JavaScript (KaTeX, MathJax) or to use a word processor's built-in equation editor. JavaScript renderers cover a useful subset of LaTeX but miss edge cases, custom packages, and advanced environments. Built-in equation editors (Microsoft Equation, Google Docs) produce visibly different typography that clashes with LaTeX documents. A server-side render from a real TeX engine avoids both problems.
PowerPoint, Keynote, and Google Slides do not support LaTeX natively. Rendering your equations as transparent PNGs lets you drag-and-drop them into any slide deck while preserving typographic quality. At 300 DPI the output stays sharp on 4K projectors and Retina displays.
SVG equations scale perfectly on any screen size and stay crisp on high-DPI devices. Unlike client-side renderers such as KaTeX or MathJax, a pre-rendered SVG requires zero JavaScript and loads instantly. This is ideal for static sites, CMSs, and email newsletters where script injection is restricted.
Slack, Discord, Notion, and most Markdown editors do not interpret LaTeX. Rendering your equation as a PNG and pasting it inline is the fastest way to communicate math in chat threads, GitHub issues, and README files. The image carries the full equation semantics without requiring the reader to install any plugin.
Word processors, Google Docs, and EPUB authoring tools have limited or no LaTeX support. Exporting your equations as high-resolution images lets you embed publication-quality math in any document format. PDF vector output is especially useful for print workflows where raster artifacts are unacceptable.
Each output format has distinct strengths. PNG is the universal fallback; SVG is best for the web; PDF is ideal for print; MathML is the accessibility standard. The table below summarizes the key differences to help you choose.
| Format | Best for | Scalability | File size | Transparency | Accessibility |
|---|---|---|---|---|---|
| PNG | Presentations, messaging, social media | Raster — fixed resolution, set DPI before rendering | Small to medium (depends on DPI and complexity) | Yes (optional alpha channel) | None — screen readers see alt text only |
| SVG | Websites, documentation, responsive design | Vector — infinite scaling, always sharp | Very small (text-based XML) | Inherent (no background by default) | Partial — can include title and desc elements |
| Print, academic papers, vector archives | Vector — lossless at any zoom level | Small (single-equation PDFs are a few KB) | Depends on viewer; generally supported | Limited — depends on tagged PDF support | |
| MathML | Accessible HTML, screen readers, semantic web | Text-based — styled by CSS, scales with font size | Minimal (pure markup) | N/A — rendered by the browser as text | Excellent — screen readers parse the math structure |
Whether you use the online tool or the REST API, the workflow follows four steps. The online tool provides a visual interface for each option; the API accepts the same parameters as JSON fields.
Enter any valid LaTeX math expression. You can use inline math ($...$), display math (\[...\]), or full environments like align, gather, and cases. The renderer supports amsmath, mathtools, physics, and siunitx packages out of the box.
E = mc^{2}Select PNG for raster images that work everywhere, SVG for scalable web graphics, PDF for print-quality vector output, or MathML for accessible HTML embedding. Each format has trade-offs — see the comparison table above.
png | svg | pdf | mathmlAdjust DPI (72 to 600), enable transparent backgrounds, set the font size (8pt to 24pt), choose a font family (Computer Modern, Latin Modern, STIX Two, TeX Gyre), and declare any additional LaTeX packages your equation needs.
dpi: 300, transparent: true, font_size: 12Click Render in the online tool or send a POST request to the API endpoint. The image is generated server-side using a full TeX Live installation — no approximation, no browser-based heuristics. Download the file or copy the direct URL for embedding.
POST /api/v1/render/equationThe default settings produce excellent results for most use cases. When you need fine-grained control over the output, the following options are available in both the online tool and the API. Each option is passed as a JSON field in the API request body.
These options can be combined freely. For example, you can render a white equation on a transparent background at 300 DPI using Latin Modern at 14pt with the siunitx package loaded — all in a single request.
Controls the pixel density of PNG output. Use 72 for quick previews, 150 for web use, 300 for print, and 600 for archival or large-format printing. Higher DPI produces larger files but sharper text at any zoom level. SVG and PDF output are resolution-independent and ignore this setting.
"dpi": 300When enabled, the PNG output has an alpha channel instead of a white background. This is essential for placing equations on colored slides, dark-mode websites, or textured backgrounds. SVG output is transparent by default.
"transparent": trueOverride the default black text with any hex color. Useful for rendering white equations for dark backgrounds, or matching your brand color palette. Background color is ignored when transparency is enabled.
"color": "#ffffff", "bg_color": "#1a1a2e"Set the base font size in points. This controls the overall scale of the rendered equation. Common values are 10pt (compact), 12pt (standard document size), 14pt (slides), and 18-24pt (large display). The renderer adjusts sub/superscript sizing proportionally.
"font_size": 14Choose the typeface used for the equation. Computer Modern is the classic LaTeX look. Latin Modern is a refined OpenType update. STIX Two and TeX Gyre Termes are alternatives that blend well with Times-based body text. The font family applies to both math and text-mode content in the equation.
"font_family": "Latin Modern"The renderer accepts any LaTeX math environment: equation, align, gather, multline, cases, matrix, bmatrix, pmatrix, and split. You can also define custom macros using \newcommand in the preamble field. The full amsmath, amssymb, mathtools, and physics packages are available.
"preamble": "\\newcommand{\\R}{\\mathbb{R}}"Request extra LaTeX packages beyond the defaults. Useful for specialized notation: siunitx for SI units, chemformula for chemistry, tikz-cd for commutative diagrams, or mhchem for chemical equations. The server has a full TeX Live installation with thousands of packages available.
"packages": ["siunitx", "chemformula"]Once you have rendered your equation, the next step is embedding it in your HTML page, blog post, or documentation site. There are three primary methods, each with different trade-offs for performance, accessibility, and ease of integration.
For most web projects, inline SVG offers the best balance of quality and performance. Use the img tag approach when you need lazy loading or CDN caching. Choose MathML when accessibility compliance (WCAG, Section 508) is required.
Paste the SVG markup directly into your HTML. This gives you full CSS control over colors and sizing, eliminates an HTTP request, and allows the equation to inherit the page font size via em units. Inline SVG is the best option for performance-critical pages with a small number of equations.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40">
<!-- SVG content from the API response -->
</svg>Point an img tag at the FormaTeX render endpoint. The browser fetches the image on demand. Add width, height, and alt attributes for layout stability and accessibility. This approach works with any CMS or static site generator and requires no build step.
<img
src="https://api.formatex.io/api/v1/render/equation?latex=E%3Dmc%5E%7B2%7D&format=svg"
alt="E equals m c squared"
width="120"
height="40"
loading="lazy"
/>MathML is the W3C standard for mathematical markup in HTML. Screen readers like JAWS, NVDA, and VoiceOver can parse MathML and read the equation aloud. Firefox renders MathML natively; Chrome and Safari require the MathJax polyfill. Use MathML when accessibility is a regulatory or ethical requirement.
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>E</mi>
<mo>=</mo>
<mi>m</mi>
<msup><mi>c</mi><mn>2</mn></msup>
</math>The FormaTeX equation rendering API accepts a POST request with a JSON body. Authenticate with a Bearer token (your API key, generated from the dashboard). The response body contains the rendered image bytes. For complete API documentation and client libraries, see the Python API guide and cURL reference.
Below are two examples: a cURL command to render a PNG at 300 DPI with a transparent background, and a cURL command to render an SVG of a Gaussian integral.
Render a PNG at 300 DPI with transparent background
# Render a LaTeX equation as a transparent PNG at 300 DPI
curl -X POST https://api.formatex.io/api/v1/render/equation \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"latex": "E = mc^{2}",
"format": "png",
"dpi": 300,
"transparent": true
}' \
--output equation.pngRender an SVG of a Gaussian integral
# Render a LaTeX equation as an inline SVG
curl -X POST https://api.formatex.io/api/v1/render/equation \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"latex": "\\int_{0}^{\\infty} e^{-x^2} \\, dx = \\frac{\\sqrt{\\pi}}{2}",
"format": "svg",
"font_size": 14
}' \
--output equation.svgRender multiple equations in a loop. Each request returns a binary image file. Useful for generating all equations in a textbook chapter or documentation set in one pass.
#!/bin/bash
EQUATIONS=("E = mc^{2}" "a^2 + b^2 = c^2" "\\sum_{n=1}^{\\infty} \\frac{1}{n^2} = \\frac{\\pi^2}{6}")
API_KEY="YOUR_API_KEY"
for i in "${!EQUATIONS[@]}"; do
curl -s -X POST https://api.formatex.io/api/v1/render/equation \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "{\"latex\": \"${EQUATIONS[$i]}\", \"format\": \"png\", \"dpi\": 300}" \
--output "equation_$i.png"
echo "Rendered equation_$i.png"
doneUse Python to render an equation and save the result. The API returns the raw image bytes in the response body. Set the Content-Type header and parse the JSON payload.
import requests
response = requests.post(
"https://api.formatex.io/api/v1/render/equation",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"latex": r"\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t}",
"format": "svg",
"font_size": 14,
},
)
with open("maxwell.svg", "wb") as f:
f.write(response.content)
print(f"Status: {response.status_code}, saved maxwell.svg")There are several ways to render LaTeX equations as images, ranging from server-side tools that run a full TeX engine to client-side JavaScript libraries that approximate LaTeX in the browser. The right choice depends on your requirements: output fidelity, format options, API access, package support, and pricing.
Server-side tools (FormaTeX, CodeCogs, LaTeX2Image, QuickLaTeX) produce output identical to compiled LaTeX because they run a real TeX engine. Client-side tools (KaTeX, MathJax) render in the browser using JavaScript and cover a large but incomplete subset of LaTeX. For a detailed comparison, see the full equation renderers comparison.
| Tool | Rendering | Formats | Customization | API |
|---|---|---|---|---|
| FormaTeX | Server-side TeX Live (full LaTeX engine) | PNG, SVG, PDF, MathML | DPI, transparency, color, font family, custom packages | REST API with batch support |
| CodeCogs | Server-side LaTeX rendering | PNG, GIF, SVG, PDF | DPI, font size, background color | URL-based (GET request with query params) |
| LaTeX2Image | Server-side LaTeX rendering | PNG, SVG | Limited — basic DPI and color options | Web form only (no API) |
| QuickLaTeX | Server-side LaTeX rendering | PNG, SVG | Font size, color, custom preamble | URL-based rendering endpoint |
| KaTeX (client-side) | JavaScript in the browser — no server needed | HTML/CSS (not images) | CSS styling, theme colors | N/A — JavaScript library |
| MathJax (client-side) | JavaScript in the browser — no server needed | HTML/CSS, SVG, MathML | Extensive CSS and configuration options | N/A — JavaScript library |
Key takeaway: If you need pixel-perfect LaTeX output with full package support and a REST API, FormaTeX is the most complete option. If you only need inline browser rendering and do not require downloadable images, KaTeX (fastest) or MathJax (broadest LaTeX coverage) are excellent open-source choices.
Open the free equation renderer, paste your LaTeX, and download a high-quality image in seconds. No account required for the online tool.
One quick thing
We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.