How I Wrote Justhtml, a Python-Based Html5 Parser, Using Coding Agents
Key topics
The creation of JustHTML, a Python-based HTML5 parser, has sparked a lively discussion about the role of coding agents in its development. EmilStenstrom, the creator, reveals that while the final product may resemble a port of the Rust library "html5ever," the initial iteration was built from scratch using coding agents, with the agents generating code from tests to achieve 100% test coverage. Commenters debate the nuances of the project's origins, with some suggesting that "cloc" is a more accurate tool for measuring code lines than "wc -l." The conversation highlights the complexities of measuring productivity and the potential benefits of using coding agents for tasks with clear right and wrong answers, like parser development.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
N/A
Peak period
11
0-12h
Avg / period
3.1
Based on 25 loaded comments
Key moments
- 01Story posted
Dec 14, 2025 at 11:26 AM EST
21 days ago
Step 01 - 02First comment
Dec 14, 2025 at 11:26 AM EST
0s after posting
Step 02 - 03Peak activity
11 comments in 0-12h
Hottest window of the conversation
Step 03 - 04Latest activity
Dec 21, 2025 at 7:49 AM EST
14 days ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
Emil Stenström wrote it with a variety of coding agent tools over the course of a couple of months. It's a really interesting case study in using coding agents to take on a very challenging project, taking advantage of their ability to iterate against existing tests.
I wrote a bit more about it here: https://simonwillison.net/2025/Dec/14/justhtml/
I cloned the repo and ran `wc -l` on the src directory and got closer to 9,500. Did i missing something?
Edit: maybe you meant just the parser
isn't this more like a port of `html5ever` from rust to python using LLM, as opposed to creating something "new" based on the test suite alone?
if yes, wouldn't be the distinction rather important?
The first iteration of the project created a library from scratch, from the tests all the way to 100% test coverage. So even without the second iteration, it's still possible to create something new.
In an attempt to speed it up, I (with coding agent) rewrote it again based on html5ever's code structure. It's far from a clean port, because it's heavily optimized Rust code, that isn't possible to port to Python (Rust marcos). And it still depended on a lot of iteration and rerunning tests to get it anywhere.
I'm not pushing any agenda here, you're free to take what you want from it!
You also mention that the current "optimised" version is "good enough" for every-day use (I use `bs4` for working with html), was the first iteration also usable in that way? Did you look at `html5ever` because the LLM hit a wall trying to speed it up?
As for bs4, if you don't change the default, you get the stdlib html.parser, which doesn't implement html5. Only works for valid HTML.
It looks to me like this is the last commit before the rewrite: https://github.com/EmilStenstrom/justhtml/tree/989b70818874d...
The commit after that is https://github.com/EmilStenstrom/justhtml/commit/7bab3d2 "radical: replace legacy TurboHTML tree/handler stack with new tokenizer + treebuilder scaffold"
It also adds this document called html5ever_port_plan.md: https://github.com/EmilStenstrom/justhtml/blob/7bab3d22c0da0...
Here's the Codex CLI transcript I used to figure this out: https://gistpreview.github.io/?53202706d137c82dce87d729263df...
FAILED: 8337/9404 passed (88.6%), 13 skipped
It seems this the parser is creating errors even when none are expected:
That said, the example you are pulling our out does not match that either. I'll make sure to fix this bug and other like it! https://github.com/EmilStenstrom/justhtml/issues/20
There's also something off about your benchmark comparison. If one runs pytest on html5lib, which uses html5lib-test plus its own unit tests and does check if errors match exactly, the pass rate appears to be much higher than 86%:
The skipped tests are just because it's not testing against the deprecated cElementTree. The XFAILED are what are expected to fail - perhaps because of the problem you described of errors not being standardized.If you're not the author, you don't own the copyright.