Inspiration
A form can clearly tell someone what to enter and still reject that answer. A password reset write up showed what happens when a field silently cuts off a pasted password. QA testers and reviewers would have to read both the instructions and the HTML to catch that kind of mismatch. I wanted an audit tool that puts the two side by side. Password reset write up
What it does
Paste a form's HTML or choose a sample. FormCandor compares the labels and help text with browser constraints. Each finding shows what the form says, what the HTML enforces, and a suggested fix. You can click a finding to highlight its field, copy a Markdown report, or download JSON. Saved sample results can be replayed offline. Try it live at formcandor.web.app.
How we built it
A Vite and TypeScript app reads the HTML and renders a sanitized preview with DOMPurify. Firebase AI Logic in hybrid mode prefers Chrome's on-device Gemini Nano and can fall back to Gemini in the cloud. App Check helps protect the Firebase AI Logic backend.
The model extracts structured rules one clause at a time. Zod validates the response, and quote checks require the original text to support each rule type and value. Deterministic code reads the HTML constraints, recognizes common instructions, compares the two sets of rules, and writes the fixes.
Challenges we ran into
- Invented constraint values. The model could return a number that did not appear in its quote. We check each value against its own quote and use code to read common instructions such as ranges and required markers.
- Requests that hung. An on-device run could stay on "Analyzing…" while a model call was pending. We added a 60-second deadline per call. When it expires, the app keeps what has finished and continues with HTML checks.
- Chrome's language option. On-device setup involves both model availability and the language the session expects. We declare English for text input and output when creating the session and send short clauses for extraction.
Accomplishments that we're proud of
We built the diagnostics page, hybrid extraction, validation and comparison, the analyzer and preview, replay, and both report exports during the submission period. The live Chrome on-device check produced the expected results for all four samples. Signup had four findings, Phone and postal code had three, File upload had four, and Clean request form had zero. Diagnostics also passed with on-device responses in C and D and a cloud response in E. With Nano switched off in a test build, the same four samples ran through the cloud fallback with the same results, and the deployed site passes the cloud test behind App Check with reCAPTCHA Enterprise.
What we learned
Small prompts made it easier to see which instruction a model missed. An exact quote is useful evidence only if it supports the rule being claimed. Separating extraction from comparison let us improve model handling while keeping the HTML checks and suggested fixes repeatable.
What's next for FormCandor
Test automatic fallback on more Chrome setups where Nano is unavailable. Expand the deterministic checks for more HTML patterns and add a way to capture a form from the page under review. Test more instruction languages against Chrome's supported model options.
Built With
- chrome
- chrome-prompt-api
- dompurify
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- gemini
- gemini-api
- gemini-nano
- jsdom
- typescript
- vite
- vitest
- zod