TeXbrain compiles LaTeX to PDF in the browser via WASM

TeXbrain compiles LaTeX to PDF in the browser via WASM

A developer released TeXbrain, a free and open source LaTeX editor that compiles .tex files to PDF entirely inside the browser, with no server processing the files. The project is credited to Braian Plaku, who says he built it after writing his thesis in LaTeX and finding that hosted editors lock git sync behind a paywall while local installs break across machines. TeXbrain runs the editor, the compiler, the PDF preview, and a git client all client side in a single browser tab: open a local project folder, edit files, watch the PDF update, commit, and push to GitHub, without installing anything or creating an account.

The compiler is SwiftLaTeX's WebAssembly port of the pdfTeX engine, running inside an in-browser memory filesystem. Recompilations take 1 to 5 seconds depending on project complexity. Common CTAN packages ship bundled with the app; anything else, such as memoir, abntex2, or KOMA-Script, resolves automatically the first time a document needs it, through a chain that checks previously cached files first, then the bundled subset, then a TeX Live mirror on jsDelivr with a community SwiftLaTeX server as fallback, and is cached afterward so the app keeps working offline. The editor itself is CodeMirror 6 with a custom LaTeX grammar and autocomplete for more than 70 LaTeX commands, plus a file tree, tabs, a command palette, and a snippet picker. The PDF preview is rendered with Mozilla's pdf.js, supporting multiple pages, zoom, and text selection. Git operations, cloning, branching, staging, committing, pushing, pulling, and merging, run through isomorphic-git, a pure JavaScript git implementation backed by an in-memory LightningFS filesystem stored in IndexedDB; because browsers cannot speak the git protocol directly, remote operations go through a configurable CORS proxy, defaulting to the isomorphic-git project's public one. Direct read and write access to a local project folder uses the File System Access API, which only Chromium based browsers (Chrome, Edge, Arc, Brave) support; Firefox and Safari fall back to a virtual, browser only filesystem.

The engine has real limits. It supports pdfTeX only, so packages that need XeTeX or LuaTeX, such as fontspec or polyglossia, will not compile. There is no bibtex or biber: biblatex documents get a plain thebibliography list generated from the .bib file instead, so references appear but the citation style is ignored, and classic bibtex workflows need a prebuilt .bbl file already in the project; a real bibtex implementation in WebAssembly is described as next on the roadmap. Bundled packages are pinned to a TeX Live 2020 era format file, so newer package versions are not available. On privacy, the project states there is no telemetry, no analytics, and no accounts; git authentication tokens are stored only in the browser's local storage; LaTeX compilation runs in a WebAssembly sandbox with no shell commands executed; and when a package is fetched from a public mirror, only its filename is sent, never the document's content. TeXbrain is MIT licensed, and the Show HN submission had drawn 89 points and 19 comments at the time this was written.

Key facts

  • TeXbrain compiles .tex files to PDF directly in the browser, using SwiftLaTeX's WebAssembly port of the pdfTeX engine, with no server processing the files.
  • Recompilations take 1 to 5 seconds depending on project complexity, and CTAN packages not bundled with the app are fetched on demand from a TeX Live mirror and cached locally for offline use.
  • The editor is built on CodeMirror 6 with autocomplete for more than 70 LaTeX commands, a live PDF preview rendered with pdf.js, and full git integration through isomorphic-git for cloning, committing, and pushing.
  • It supports pdfTeX only, so packages requiring XeTeX or LuaTeX such as fontspec or polyglossia will not compile, and it ships neither bibtex nor biber, generating a plain bibliography list instead.
  • TeXbrain is free and open source under the MIT license, collects no telemetry and requires no account, and its creator, Braian Plaku, says git authentication tokens stay in the browser's local storage and never reach a server he controls.

Why it matters

TeXbrain removes the two standard complaints about LaTeX tooling: hosted editors that gate git sync behind a paywall, and local installs that break across machines. It runs the whole pipeline, editing, compiling, previewing, and git, inside one browser tab, with nothing to install and no account to create. The author says he built it after writing a thesis in LaTeX and spending more time fighting tooling than writing.

Who it affects

Anyone who writes in LaTeX: students, academics, and anyone drafting a thesis, paper, CV, or beamer presentation, especially people currently paying a hosted editor for git sync or juggling a local TeX Live install across several machines. Browser choice matters here: full functionality, including direct read and write access to a local project folder, needs a Chromium based browser (Chrome, Edge, Arc, Brave), because it depends on the File System Access API; Firefox and Safari fall back to a virtual, browser only filesystem instead.

How to use it

The project is free and open source under the MIT license, usable directly at tex.swimmingbrain.dev with no installation and no account, or run locally by cloning the GitHub repository and running pnpm install and pnpm dev, then opening it at localhost:5173 in Chrome or Edge. It ships templates to start from: article, thesis, beamer, report, CV, and letter.

How solid is it

The build reuses established components rather than reimplementing them: the compiler is SwiftLaTeX's WebAssembly port of pdfTeX, the editor is CodeMirror 6 with a custom LaTeX grammar, git runs through isomorphic-git backed by an in-memory LightningFS filesystem over IndexedDB, and the PDF is rendered with Mozilla's pdf.js. Packages not bundled with the app resolve through a cache first chain, previously downloaded files, then the bundled subset, then a TeX Live mirror on jsDelivr with a community SwiftLaTeX server as fallback, so each package downloads only once and the app keeps working offline afterward. The Show HN post had drawn 89 points and 19 comments at the time it was retold.

Risks and caveats

The engine supports pdfTeX only, so documents needing XeTeX or LuaTeX, such as fontspec or polyglossia, will not compile. There is no bibtex or biber: biblatex documents get a plain thebibliography list generated from the .bib file instead, so references show up but the citation style is not honored, and classic bibtex workflows need a prebuilt .bbl file already in the project; a real bibtex implementation in WebAssembly is described as next on the roadmap. Bundled CTAN packages are pinned to a TeX Live 2020 era format file, so newer package versions are unavailable. Pushing or pulling from a git remote requires a CORS proxy, since browsers cannot speak the git protocol directly; the default is the isomorphic-git project's public proxy, replaceable with a self-hosted one. Direct read and write access to a local folder works only in Chromium based browsers.

“I built this because I was tired of paying for features that should be free.”

— Braian Plaku, TeXbrain's developer