Skip to content

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.

<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 &amp; and < as &lt; (including any literal </textarea>). If your site generates the form from JavaScript, populate an <input type="hidden" name="encoded_snip"> with encodeURIComponent(code) instead.

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>

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>
  • URL: POST https://jointtex.com/open
  • Accepted encodings: application/x-www-form-urlencoded or multipart/form-data (text fields only; file uploads are rejected).
  • HTTP method: POST only. Visiting GET https://jointtex.com/open directly displays an informational page with a link to the integration guide.
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:

  1. Root file selection: If main_document is omitted, JointTex searches files matching the explicit engine’s language (or .tex files first, then .typ files when no engine is given). It picks the only matching file, otherwise main.tex / main.typ if it is a complete document, otherwise the first complete document, otherwise the first matching file. A .tex file is considered complete if it contains \documentclass; any .typ file is complete.
  2. Engine detection: For a .typ root, the engine is always typst. For a .tex root without an explicit engine, JointTex checks the first 20 lines for a % !TEX program = <engine> (or TS-program) magic comment; failing that, it selects xelatex if the root contains CJK characters, otherwise pdflatex.
  3. Single-file fragment wrapping: If a submission contains exactly one .tex file and it has no \documentclass, JointTex wraps it in a minimal \documentclass{article} document (ctexart when CJK text is present and the engine is not pdflatex or latex) so it compiles immediately. Typst code is never wrapped.

JointTex keeps the /open flow stateless on the server until the reader confirms creation:

  1. POST /open does not require cookies, does not read the reader’s session, and writes nothing to the server database.
  2. The server validates the payload and returns the JointTex web shell (Cache-Control: no-store) with the parsed files embedded as inert JSON.
  3. 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.
  4. 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 and visit.
  5. 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 the visit UUID guarantees idempotency so double-clicks, reloads, or Back navigation never create duplicate projects.
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.

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 .cls files from a GitHub README? Publish the template to the JointTex Template Gallery and link it with an official Open in JointTex badge.