Redacting selected text

A letter drawn by a canvas. Select part of it and press “Redact selection”, or let the page find the numbers and the email address. The canvas covers those ranges with a bar, large pixels, a blur or changing letters. The table under the letter shows where the covered text can still be read.

Notice of a refund

Dear Ms Okafor, we charged account 4417 2203 9951 twice on 3 March. The second payment of 1,240.00 was a mistake and has been returned.

If the money hasn't arrived within five working days, write to billing@example.com or call 020 7946 0321 and quote reference RF-88213.

We are sorry for the trouble. Nothing else on the account has changed.

Nothing is redacted.

Where the redacted text can still be read

Show the code ranges, the four styles, copy and removal
  1. The letter inside <selection-fx> with the effect named redact.
  2. Keep the redacted ranges as offsets and in a Custom Highlight that has no style, which the element measures.
  3. Bar. A filled rectangle over each line of each range.
  4. Pixels. The canvas copied into large cells.
  5. Blur. The element drawn again through ctx.filter and a clip.
  6. Changing letters.
  7. Copy. Replace redacted characters in the clipboard text.
  8. Remove the text from the DOM.

How it works

“Redact selection” stores the selection as two character offsets and adds a Range for it to a CSS Custom Highlight with no ::highlight() rule. The element reads the rectangles of that Highlight's ranges and the effect draws over them after it has drawn the text. The drawing is only pixels. The characters stay in the DOM, so anything that reads the DOM still gets them: copy, textContent, find-in-page, a screen reader. “Remove the text from the DOM” replaces each redacted character with a block character, after which the canvas bar covers blocks.

Live checks

These start when you press the button. They use their own fixture.

Findings

Measured in headless Chromium 157 on Linux with a software renderer, 2026-11-21.

Not verified: what find-in-page and TalkBack report for a redacted range (both read the DOM, so the expected answer is the original text until it's removed), and selecting by touch on a phone.