Open in JointTex (/open)
Any website, blog, course portal, or documentation page can place an Open in JointTex button next to a LaTeX or Typst example. The button is a plain HTML <form> that POSTs the code to https://jointtex.com/open — no JavaScript SDK, API key, or JointTex account is required on your site.
The form field names match Overleaf’s /docs endpoint, so existing Overleaf snippet forms work by changing only the action URL. JointTex also adds first-class support for Typst.
Quick example
Section titled “Quick example”Single LaTeX file
Section titled “Single LaTeX file”<form action="https://jointtex.com/open" method="post" target="_blank"> <textarea name="snip" hidden>\documentclass{article}\begin{document}Hello, JointTex!\end{document} </textarea> <button type="submit">Open in JointTex</button></form>Inside a
<textarea>, escape&as&and<as<(including any literal</textarea>). If your site generates the form from JavaScript, populate an<input type="hidden" name="encoded_snip">withencodeURIComponent(code)instead.
Multiple files
Section titled “Multiple files”Repeat snip[] (or encoded_snip[]) for each file and provide matching relative paths in snip_name[] in the same order:
<form action="https://jointtex.com/open" method="post" target="_blank"> <input type="hidden" name="encoded_snip[]" value="...main.tex, encoded with encodeURIComponent..."> <input type="hidden" name="snip_name[]" value="main.tex"> <input type="hidden" name="encoded_snip[]" value="...refs.bib, encoded..."> <input type="hidden" name="snip_name[]" value="refs.bib"> <input type="hidden" name="main_document" value="main.tex"> <input type="hidden" name="engine" value="xelatex"> <button type="submit">Open in JointTex</button></form>Typst example
Section titled “Typst example”Set engine to typst (or name the root file *.typ):
<form action="https://jointtex.com/open" method="post" target="_blank"> <textarea name="snip" hidden>= Hello, JointTex!Typst sets this paragraph. </textarea> <input type="hidden" name="engine" value="typst"> <button type="submit">Open in JointTex</button></form>Endpoint and content types
Section titled “Endpoint and content types”- URL:
POST https://jointtex.com/open - Accepted encodings:
application/x-www-form-urlencodedormultipart/form-data(text fields only; file uploads are rejected). - HTTP method:
POSTonly. VisitingGET https://jointtex.com/opendirectly displays an informational page with a link to the integration guide.
Form fields reference
Section titled “Form fields reference”| Field | Repeatable | Description |
|---|---|---|
snip / snip[] |
Yes | Raw UTF-8 text of a file. Browser CRLF line endings are normalized to LF. |
encoded_snip / encoded_snip[] |
Yes | Percent-encoded UTF-8 text (encodeURIComponent). If decoding fails (for example, unencoded LaTeX % comments sent by runlatex.js), the value is accepted as raw text. |
snip_name / snip_name[] |
Yes | Relative file path for each snippet in the same order (subfolders such as chapters/intro.tex are allowed). Unnamed first file defaults to main.tex (main.typ when engine=typst); subsequent unnamed files default to snippet-2.tex, snippet-3.tex, and so on. |
main_document |
No | Exact relative path of the root .tex or .typ file to compile. Must match one of the submitted files. |
engine |
No | Compiler engine: pdflatex, xelatex, lualatex, latex (Overleaf’s latex_dvipdf alias is mapped to latex), or typst. Unknown engines or language mismatches (for example typst with a .tex root) are rejected. |
Automatic root, engine, and fragment detection
Section titled “Automatic root, engine, and fragment detection”When optional fields are omitted, JointTex resolves the build configuration deterministically:
- Root file selection: If
main_documentis omitted, JointTex searches files matching the explicitengine’s language (or.texfiles first, then.typfiles when no engine is given). It picks the only matching file, otherwisemain.tex/main.typif it is a complete document, otherwise the first complete document, otherwise the first matching file. A.texfile is considered complete if it contains\documentclass; any.typfile is complete. - Engine detection: For a
.typroot, the engine is alwaystypst. For a.texroot without an explicitengine, JointTex checks the first 20 lines for a% !TEX program = <engine>(orTS-program) magic comment; failing that, it selectsxelatexif the root contains CJK characters, otherwisepdflatex. - Single-file fragment wrapping: If a submission contains exactly one
.texfile and it has no\documentclass, JointTex wraps it in a minimal\documentclass{article}document (ctexartwhen CJK text is present and the engine is notpdflatexorlatex) so it compiles immediately. Typst code is never wrapped.
Reader experience and security model
Section titled “Reader experience and security model”JointTex keeps the /open flow stateless on the server until the reader confirms creation:
POST /opendoes not require cookies, does not read the reader’s session, and writes nothing to the server database.- The server validates the payload and returns the JointTex web shell (
Cache-Control: no-store) with the parsed files embedded as inert JSON. - The browser stores the draft locally under a random 128-bit ID in
localStorage(up to the 5 newest drafts, 1.5M characters total, retained for 7 days; private windows keep the draft in tab memory) and replaces the URL with/open/<draftId>?visit=<uuid>so reloads never resubmit the form. - On
/open/<draftId>, the reader inspects every file, the target engine, and your site’s origin. Signed-out readers sign up or sign in and return to the same draft andvisit. - Clicking Create project submits the draft to the same-origin authenticated endpoint
POST /api/snippets/project, proposing a name from\title{...}when present. The new project is private to the reader, and thevisitUUID guarantees idempotency so double-clicks, reloads, or Back navigation never create duplicate projects.
Limits and error codes
Section titled “Limits and error codes”| Constraint | Limit |
|---|---|
| Total raw POST body size | 3 MiB |
| Maximum file count | 20 files |
| Maximum single file size (UTF-8) | 256 KiB |
| Maximum combined files size (UTF-8) | 512 KiB |
| Maximum relative path length (UTF-8) | 255 bytes |
| Binary attachments / remote fetches | Refused (snip_uri, zip_uri, and multipart file uploads are not accepted) |
Path validation also enforces safe relative paths, blocks NUL bytes, blocks the reserved .jointtex/ directory, blocks case-insensitive path collisions, and verifies the root file name is compilable.
When a submission is refused, JointTex responds with 303 See Other to /open?error=<reason> so the reader lands on a readable explanation page:
error value |
Meaning |
|---|---|
invalid |
Missing snippet text, more snip_name[] values than files, invalid path or root file, invalid engine, or engine/file language mismatch. |
too-large |
Request body exceeded 3 MiB, a single file exceeded 256 KiB, or total file bytes exceeded 512 KiB. |
too-many |
More than 20 files submitted. |
unsupported |
snip_uri, zip_uri, or a multipart file attachment was sent. |
Attribution and privacy
Section titled “Attribution and privacy”JointTex reads only the scheme and host of the browser’s Origin header (falling back to Referer origin) to show the reader where the code came from and to aggregate anonymous project-creation counts per referring site. Individual page URLs and reader identities are not recorded in referral counts.
Need to distribute a full template with figures, fonts, or
.clsfiles from a GitHub README? Publish the template to the JointTex Template Gallery and link it with an official Open in JointTex badge.
