FxEditor
User guideQuickstartDeploymentAPIDesignFxTeX
APIExamplesRight-click menuAccessibilityFxTeX Server
OverviewAPIAccess and keysSelf-hosting
Plugins
OverviewCKEditor 5TinyMCE 6 and 7BloggerAngularFroalaTiptapWordPressMoodleGoogle Docs and SlidesCanvas, Blackboard and LTITiddlyWikiWriting your ownLicensing
How licensing worksfxTeX Server API
One URL, three parts:
https://fxtex.codecogs.com/type.format?LaTeX
type is what is produced, format is how it is delivered, and everything after
the ? is the equation. There is no session, nothing to configure, and nothing kept
between requests. This is the same interface LaTeXRender had at https://latex.codecogs.com,
which now redirects here.
In an image tag
The simplest use, and the most common: an equation is an <img>.
<img src="https://fxtex.codecogs.com/svg.image?1+\sin^2(x)" />
<img src="https://fxtex.codecogs.com/png.image?\int_a^b \frac{1}{x}\,dx = \ln\frac{b}{a}" />
An SVG carries its own accessible label, so a screen reader announces the equation rather than
the file name. For a PNG or GIF, give the <img> an alt.
Type
| Type | Produces |
|---|---|
svg | A vector image with every character embedded as an outline. Draws correctly anywhere, with no font installed. |
svgtext | The same, with characters left as <text>. Around a sixth of the size and selectable, but needs Latin Modern Math on the machine that displays it. A symbol that font cannot draw is still embedded as an outline. |
png | A bitmap of that SVG. |
gif | The same, as a GIF. |
pdf | A vector PDF of the equation. |
mathml | MathML markup, with the spoken form of the equation attached for screen readers. See MathML below. |
mathml_nospeech | The bare <math> element, with no spoken text. |
Format
| Format | Delivers |
|---|---|
image | The result itself: the image bytes, or the markup for mathml. The default when the format is missing or not recognised. |
json | A JSON object wrapping the result, with any conversion errors. See JSON. |
download | As image, but sent as a file download named equation.svg, equation.png and so on. |
The older .latex format — gif.latex?x^2,
png.latex?x^2 — is still accepted, and behaves as .image.
Size, resolution and colour
These go at the front of the equation itself, in any order:
| Write | Effect |
|---|---|
\inline | Lays the equation out to sit in a line of text, rather than as a display equation: fractions, sums and limits are set smaller. |
\tiny … \Huge | Any of LaTeX's ten size commands: \tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge, \Huge. |
\dpi{n} | Resolution of a png or gif. \dpi{96} is one image pixel per CSS pixel; \dpi{192} is twice that, for high-density screens. |
\bg{colour} | Background colour. Transparent if not given. |
\fg{colour} | Colour of the equation itself. |
A colour is any CSS colour name
— navy, crimson, white — or a hex value of three
or six digits, with or without the #: \fg{c00},
\fg{#cc0000}. An unrecognised colour is ignored rather than treated as part of the
equation.
<img src="https://fxtex.codecogs.com/png.image?\dpi{150}\bg{white}\fg{navy}\large e^{i\pi}+1=0" />
Escaping an equation into a URL
Most LaTeX can be written into a URL as it is, and browsers will percent-encode it for you. Four characters need care, because they either end the query string or change meaning inside one:
| Character | Send as | Why |
|---|---|---|
+ | %2B or + | Some software turns a bare + in a query string into a space. |
| space | %20 or &space; | Spaces matter in LaTeX: \alpha b is not \alphab. |
& | %26 | A bare & can start a new parameter. Matrices are full of them. |
# | %23 or &hash; | A bare # starts a fragment, and nothing after it is ever sent. |
The named forms (+, &space;, &hash;) are
what the equation editor writes. They survive being pasted into HTML and through template engines
that would mangle a %2B.
From code, encode the whole equation. In JavaScript:
const latex = '\\begin{pmatrix}a&b\\\\c&d\\end{pmatrix}';
const url = 'https://fxtex.codecogs.com/svg.image?' + encodeURIComponent(latex);
Beware form encoders — Java's and Kotlin's URLEncoder, PHP's
urlencode — which write a space as +. That reads here as a plus.
Use rawurlencode in PHP, or replace + with %20 afterwards.
MathML
mathml returns markup rather than a picture, for inserting into a page yourself. It
is accessible by default: the spoken form of the equation sits beside the
<math>, which is hidden from screen readers so they announce one or the other,
never both.
curl "https://fxtex.codecogs.com/mathml.image?x%5E2"
<span class="cc-math fxtex"><math aria-hidden="true" class="fxtex" display="block" title="x^2">
<msup><mi>x</mi><mn>2</mn></msup>
</math><span class="cc-speech">x squared</span></span>
The spoken text is hidden from sight by a stylesheet, which also makes small improvements to the browser's own MathML layout. Link it on any page that shows this markup — without it, the words appear as ordinary text beside the equation:
<link id="fxtex-style" rel="stylesheet" href="https://fxtex.codecogs.com/fxtex.css">
If you would rather leave accessibility to the browser's own MathML support, ask for
mathml_nospeech, which returns the bare <math> element.
The MathML is identical, character for character, to what fxTeX produces in the browser for the same input — the two share one converter.
JSON
Any type with the json format returns the result wrapped in an object, together with
anything the converter could not understand:
https://fxtex.codecogs.com/svg.json?1+\sin^2(x) https://fxtex.codecogs.com/png.json?1+\sin^2(x) https://fxtex.codecogs.com/mathml.json?1+\sin^2(x)
{ "latex": {
"type": "png",
"equation": "x^2",
"valid": true,
"base64": "iVBORw0KGgoAAAANSUhEUgAAAD4AAAA1CAYAAAAZBliH...",
"errors": []
} }
| Field | Meaning |
|---|---|
type | The type that was asked for. |
equation | The equation as received. |
valid | true when the equation converted with no errors at all. |
base64 | For png, gif and pdf: the file, base64-encoded. |
svg / mathml | For the text types: the markup itself, as a string. svgtext uses svg, and mathml_nospeech uses mathml. |
errors | Human-readable problems — an unknown command, a symbol the font has no glyph for. Empty when valid is true. |
notice | Present only when the request came from an unregistered site. See Access and keys. |
An error does not fail the request. The converter draws what it understood and lists what it
did not, so one unknown command in a long equation costs you that command, not the equation. The
errors list is the way to find out which of your equations use something we do not
yet support — and it is a list we would like to see.
Fetching an SVG as JSON and turning it into an image:
fetch('https://fxtex.codecogs.com/svg.json?' + encodeURIComponent('1+\\cos^2(x)'))
.then(r => r.json())
.then(({ latex }) => {
const img = document.createElement('img');
img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(latex.svg);
img.alt = latex.equation;
document.body.append(img);
});
Status codes
| Status | Meaning |
|---|---|
200 | The equation, even if some of it could not be converted — see errors above. A request from an unregistered site, or with a key that is not recognised, also receives 200, with a small notice added to the image. |
429 | A registered domain or key has gone past its allowance for the moment. A Retry-After header says how many seconds to wait. For an image type the body is a picture saying so, so a page shows an explanation rather than a broken image. |
What decides which of these you get is on Access and keys.
More
Access and keys — registering a domain, licence keys for apps, and request allowances.
Overview — what fxTeX Server is, and what changed from LaTeXRender.
fxTeX — the same converter running in the browser, with no request per equation.
fxEditor — letting your users write the equations in the first place.
CodeCogs®