The CodeCogs LaTeX Engine is designed to rapidly deliver beautiful equations for consumption across website and mobile devices everywhere. To get started try using the Equation Editor to produce HTML-friendly code that can be copied into any website as an image.
To request an equation create a URL in the following format:
https://latex.codecogs.com
/ type
. format
? LaTeX
where
type is the output graphical format:
png | The most universally supported format for all platforms. |
gif | The oldest supported format for all platforms. We also embed baseline offset within the header of the GIF image format. |
svg | A vector-based graphic that is rapidly becoming standard across all browsers and will be the main format Codecogs supports going forward. |
emf | A vector-based graphic popular within Windows and Adobe Illustrator. |
A vector-based Portable Document Format (can only be used with download). |
format defines how the rendered image is received:
image | An graphical image in the desired type. |
json | A javascript JSON array with th rendered equation details. |
javascript | Similar to json but wrapped in a function called ParseEqn(). |
download | Identical to image except it triggers a browser to download the file instead of displaying it. |
LaTeX contains the LaTeX markup that defines the equation. Additional options can also be provided as part of the equation definition, which include:
\tiny | 5pt font size |
\small | 9pt font size |
\large | 12pt font size |
\LARGE | 18pt font size |
\huge | 20pt font size |
\dpi{#} | Dots per inch for png and gif images. Values from 50 to 300 |
\bg{#} | Background color, with either a preset or 6 digit hexadecimal RGB color code (e.g. 'ff0000' for red |
\fg{#} | Foreground color, with either a preset or 6 digit hexadecimal RGB color code. |
Present colors include:
amber | FFBF00 |
amethyst | 9966CC |
apricot | FBCEB1 |
aquamarine | 7FFFD4 |
azure | 007FFF |
beige | F5F5DC |
black | 000000 |
blue | 0000FF |
blush | DE5D83 |
bronze | CD7F32 |
brown | 964B00 |
burgundy | 800020 |
byzantium | 702963 |
carmine | 960018 |
cerise | DE3163 |
cerulean | 007BA7 |
champagne | F7E7CE |
chocolate | 7B3F00 |
coffee | 6F4E37 |
copper | B87333 |
coral | FF7F50 |
crimson | DC143C |
cyan | 00FFFF |
emerald | 50C878 |
erin | 00FF3F |
gold | FFD700 |
gray | 808080 |
green | 008000 |
harlequin | 3FFF00 |
indigo | 4B0082 |
ivory | FFFFF0 |
jade | 00A86B |
lavender | B57EDC |
lemon | FFF700 |
lilac | C8A2C8 |
lime | BFFF00 |
magenta | FF00FF |
maroon | 800000 |
mauve | E0B0FF |
ochre | CC7722 |
olive | 808000 |
orange | FF6600 |
orchid | DA70D6 |
peach | FFE5B4 |
pear | D1E231 |
pink | FD6C9E |
plum | 8E4585 |
puce | CC8899 |
purple | 800080 |
raspberry | E30B5C |
red | FF0000 |
rose | FF007F |
ruby | E0115F |
salmon | FA8072 |
sangria | 92000A |
sapphire | 0F52BA |
scarlet | FF2400 |
silver | C0C0C0 |
tan | D2B48C |
taupe | 483C32 |
teal | 008080 |
turquoise | 40E0D0 |
ultramarine | 3F00FF |
violet | 7F00FF |
viridian | 40826D |
white | FFFFFF |
yellow | FFFF00 |
At the simplest and most fundamental level, equations are created using a single HTML image tag, e.g:
<img src="https://latex.codecogs.com/png.image?1+sin^2(x)" />
<img src="https://latex.codecogs.com/svg.image?1+cos^2(x)" />
Output:
Image like this are used extensively across the internet and mobile platforms, all without having to install anything.
To retrieve the image in a JSON format with base64 encoding, use the one of the above image formats with .json encoding, e.g
https://latex.codecogs.com/png.json?1+sin^2(x) https://latex.codecogs.com/svg.json?1+cos^2(x) https://latex.codecogs.com/gif.json?1+cos^2(x)
Example Output:
{
"latex": {
"type":"png",
"equation":"1+sin^2(x)",
"site":"localhost:8000",
"file":"2549636a77dcfb9f09ea7ea110f10a1a_2ff.png",
"url":"https://latex.codecogs.com/eq/25/49/2549636a77dcfb9f09ea7ea110f10a1a_2ff.png",
"base64":"iVBORw0KGgoAAAANSUhEUgAAAFYAAAAVBAMAAAAutAQGAAAAMFBMVEX/
//8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3a
B7AAAAD3RSTlMARM0yInYQiatmmVTd77sbBE1NAAAACXBIWXMAAA7EAAAOxAGVKw4b
AAABgElEQVQoFYWRP0jDQBTGv7SXNmdsG11EuhQXB5fg4qSNglREMG66ZVLEDsFNXQ
ou2YzgoNDBQewaVIQ41aVzRXDu5NzJTerd5cTG9M8bvvfe93685O6AERGejhjGR8TW
3LgzvEuXaAfI2IJQh3PRJMv2alGZuWV52oyaPlWasqk6wI6sQ2C9LFlm/wYxZHXOck
nWKZYLkr2UXl9STQu6L41sMJKdgo28JVmllmDpzVX6Bfre4bVJej0XOYYW72bvgXaC
DXFylDNXl329IxZOAulgxX8Fugn22HSMbQR1qOybLNYAFWWH/fWHZCc8b87zXDbb+g
7AnrYBzRbsItddLq3EXlS6eAfeULA4gCqXBS7t/2wqQFtvGqSLB4UD/GwK+WIXIlhD
eIjuV4NiZ12fltCgwk85qNMWtUA6OLiYN4UZsUoxRPrMUX0sPQtbDVB5mnkEqB/t5D
rg3bhNakx45B2RhOz/lbHqU3YbMXdwsylt9nJjQwkEQqNTjcEtMSfAD6j8THVOt4hN
AAAAAElFTkSuQmCC"
}
}
The JSON tags are:
type | The graphical format of the equation. |
equation | The request equation after it have been cleaned, removing hundreds of common errors often make with LaTeX. |
site | The website making the request. We use this for setting CORS permission so the image can be viewed on other websites. |
file | A unique name we assign to the image you requested. |
url | The unique url of the cached image on our servers. Please note the cache is routinely cleaned so equations not used repeatible within 48 hours are removed. |
width | The width of the image. [GIF only] |
height | The height of the image. [GIF only] |
base64 | The base64 encoding of the image. |
The following example show how you might use jQuery to fetch an SVG image in base64 format and create an image icon:
$.getJSON('https://latex.codecogs.com/svg.json?1+cos^2(x)', function(icon) {
var imgElem = document.createElement('img');
imgElem.src = `data:image/svg+xml;base64,${icon.base64}`;
imgElem.alt = icon.equation;
imgElem.title = icon.equation;
$("body").append(imgElem); // Appends the new image to the page
});