Three prompts to have Claude Code build a LaTeX tool that lives entirely in the URL #fragment
Inspired by Tiny Little Office, Simon Willison used three Claude Code prompts to build a single-page LaTeX renderer whose (optionally compressed) content lives in the URL #fragment, so the link is the document; follow-ups added an iframe sandbox against XSS and URL/Gist loading.
Visit site Claude Code ↗- Pricing
- Paid
- Region
- Global
- Where it's from
- Overseas
- Added
- Oct 17, 2026
- Tested on
- Oct 17, 2026
- Version we used
- tools.simonwillison.net/latex (checked 2026-10-17); prompts from simonwillison.net 2026-10-15
- Categories
- CodingProductivity
- Original author
- Simon Willison @simonw ↗
- Our test
- Partly tested
- Cost / time
- Needs Claude Code (paid). The output is a static single page you can host free on GitHub Pages or any static host.
The task
Build a tiny tool with no backend or database where whatever you write becomes a bookmarkable, shareable link.
Steps
- Open Claude Code in your tools repo and send the first prompt (below): LaTeX in the #fragment, an optional prefix for compression with a LaTeX-tuned dictionary, the best CDN render library, and an editor with a bookmarkable Rendered toggle when there is no fragment.
- Second prompt: "Safe from XSS? We could run in an iframe sandbox like we do on the SVG markdown render project" — Simon pointed it at his existing tool's <iframe sandbox> approach.
- Third prompt: "We should have an option to load latex from a URL (or gist) similar to the markdown SVG tool".
- Open the page, paste LaTeX, switch to Rendered, and share the address-bar link; the recipient sees the same content.
- Optional: add an llms.txt (as Tiny Little Office does) so other agents know how to construct renderable links.
Prompt
I want a tool where you can link to it with a fragment hash #code-here and it treats that code as LaTeX and renders it really effectively. It should also support a prefix which means the latex is compressed with a custom compression dictionary optimized for latex. Use the best available latex render library from a CDN (consider WebAssembly too). If loaded without a fragment hash show an editor you can paste latex into and then toggle to a "rendered" view. That rendered view should be bookmarkable. The #fragment view should let you switch to edit source too.
What the author says
Simon Willison (2026-10-15) published all three prompts and the Claude Code session link. The result, tools.simonwillison.net/latex, uses Pako 2.1.0, MathJax 4.1.3, faster-latex 0.3.1 and DOMPurify 3.4.16, with Edit/Rendered toggle, URL or Gist loading, and readable or compressed share links. He used Claude Code (Opus 5.5 Extra).
Our test
We did not re-run the three prompts in Claude Code. We only checked the published result: the page loads, and its source contains the implementation details the post describes.
What we found when we tried it:On 2026-10-17 tools.simonwillison.net/latex returned HTTP 200. Its source contains location.hash and a hashchange listener, pako 2.1.0 deflate/inflate calls, MathJax 4.1.3, DOMPurify, an iframe with sandbox="allow-scripts", and Gist-loading logic.
How to get in
English blog and tool page. Reproducing needs Claude Code, though the prompt works as a spec for any coding agent.
Who it suits
Anyone building quick no-backend share tools (formulas, diagrams, checklists, small docs), and people learning to iterate prompts in rounds.
Pitfalls
- Rendering user-supplied content risks XSS — Simon spent a whole prompt on an iframe sandbox; don't skip it.
- Prompts two and three reference tools already in Simon's repo; without similar references, spell out the sandbox and Gist-loading requirements.
- Everything lives in the URL, so long documents mean long links — hence the compression prefix.
- Fragments aren't sent to the server but do persist in browser history and wherever you share them; avoid sensitive content.
More in this category
- A demo video per docs page that flags itself when the UI changesVideoScreenplayClaude CodeTool free; uses your agent's quota◐ Partly testedOverseas
- AI backend code that guards against races, leaks and bad migrationsCodingbackendskillsClaude CodePostgreSQLFree; about 2× tokens per task◐ Partly testedOverseas
- An afternoon of AI work, a 3D action game you play in the browserCodingClaude CodeTripoJimengSkill free; Claude quota plus asset tools◐ Partly testedChina
- Keep a long-running AI-built project from turning into a messCodingClaudeCodexoil-delegateNeeds Claude and Codex plans◐ Partly testedChina
- Use a web app once and get an AI write-up of how it worksResearchREAClaude CodeChromeFree tools; needs Claude or Codex◐ Partly testedOverseas