FormaTeX

\render{equation-to-image}

Render LaTeX Equations as Images

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.

Why render equations as images?

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.

Presentations and slides

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.

Websites and blog posts

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.

Messaging and documentation

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.

Non-LaTeX documents

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.

Output formats compared

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.

PNG

Best for
Presentations, messaging, social media
Scalability
Raster — fixed resolution, set DPI before rendering
File size
Small to medium (depends on DPI and complexity)
Transparency
Yes (optional alpha channel)
Accessibility
None — screen readers see alt text only

SVG

Best for
Websites, documentation, responsive design
Scalability
Vector — infinite scaling, always sharp
File size
Very small (text-based XML)
Transparency
Inherent (no background by default)
Accessibility
Partial — can include title and desc elements

PDF

Best for
Print, academic papers, vector archives
Scalability
Vector — lossless at any zoom level
File size
Small (single-equation PDFs are a few KB)
Transparency
Depends on viewer; generally supported
Accessibility
Limited — depends on tagged PDF support

MathML

Best for
Accessible HTML, screen readers, semantic web
Scalability
Text-based — styled by CSS, scales with font size
File size
Minimal (pure markup)
Transparency
N/A — rendered by the browser as text
Accessibility
Excellent — screen readers parse the math structure

Step-by-step: Render with FormaTeX

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.

Step 1

Write your LaTeX equation

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}
Step 2

Choose an output format

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 | mathml
Step 3

Configure rendering options

Adjust 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: 12
Step 4

Render and download

Click 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/equation

Advanced rendering options

The 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.

DPI (dots per inch)

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": 300

Transparent background

When 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": true

Text and background color

Override 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"

Font size

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": 14

Font family

Choose 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"

Math environments and macros

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}}"

Additional packages

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"]

Embedding equations on the web

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.

Inline SVG

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.

html
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40">
  <!-- SVG content from the API response -->
</svg>

Image tag with API URL

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.

html
<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 for accessibility

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.

html
<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>

Using the API

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.png

Render 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.svg

More API examples

Batch rendering with a script

Render 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.

bash
#!/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"
done

Python with requests

Use 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.

python
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")

FormaTeX vs alternatives

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.

FormaTeX

Rendering
Server-side TeX Live (full LaTeX engine)
Formats
PNG, SVG, PDF, MathML
Quality
Identical to compiled LaTeX — pixel-perfect typography
Customization
DPI, transparency, color, font family, custom packages
API
REST API with batch support
Pricing
Free tier + paid plans with higher limits

CodeCogs

Rendering
Server-side LaTeX rendering
Formats
PNG, GIF, SVG, PDF
Quality
Good — uses a LaTeX engine on the server
Customization
DPI, font size, background color
API
URL-based (GET request with query params)
Pricing
Free with watermark; paid for removal

LaTeX2Image

Rendering
Server-side LaTeX rendering
Formats
PNG, SVG
Quality
Good — standard LaTeX output
Customization
Limited — basic DPI and color options
API
Web form only (no API)
Pricing
Free

QuickLaTeX

Rendering
Server-side LaTeX rendering
Formats
PNG, SVG
Quality
Good — WordPress plugin integration
Customization
Font size, color, custom preamble
API
URL-based rendering endpoint
Pricing
Free

KaTeX (client-side)

Rendering
JavaScript in the browser — no server needed
Formats
HTML/CSS (not images)
Quality
Very good for supported subset; some LaTeX commands unsupported
Customization
CSS styling, theme colors
API
N/A — JavaScript library
Pricing
Free and open source

MathJax (client-side)

Rendering
JavaScript in the browser — no server needed
Formats
HTML/CSS, SVG, MathML
Quality
Excellent for supported subset; broader than KaTeX
Customization
Extensive CSS and configuration options
API
N/A — JavaScript library
Pricing
Free and open source

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.

Frequently asked questions

Render your first equation

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.

Cookie policy