Lesson 5
HTML Entity Debugging Workflow
Step-by-step checks for logs, exports, and mixed entity strings.
When entity output looks wrong, work from the stored bytes outward—not from what the browser happens to display.
Step 1: Identify the source layer
Ask:
- Is this field stored escaped, rendered escaped, or both?
- Did a CMS, API, or template last touch the string?
- Is the bug in one row or every row of an export?
Step 2: Decode to inspect characters
Paste the string into a decoder. Check:
- Do
&sequences collapse to single&? - Are there mixed named and numeric entities in one value?
- Does round-trip encode → decode match the original text?
Step 3: Watch invisible whitespace
Compare normal spaces, tabs, and . A preview that marks nbsp as · and tabs as → saves hours in CMS debugging.
Step 4: Batch problematic exports
For CSV or log dumps, process line by line. Invalid entities should report the line number and the exact token (for example &bad; or &#xZZ;).
Step 5: Fix at the correct boundary
- If double-encoded: remove one escape pass or decode before the template layer
- If under-encoded: escape at output, not at every intermediate storage step
- If wrong entity style: align encoder settings with the downstream consumer
Step 6: Verify in context
After fixing, view the final HTML or email in the target environment. Browser devtools show parsed DOM text, which may differ from the raw entity string in your database.