PDF redaction library and API

Redact PDFs in JavaScript, Python or your browser

Forme's open-source redaction removes the content, not just covers it. Try it on a sample document or your own PDF right here, then take it into your code. It runs in this browser tab: your file isn't uploaded, and there is nothing to sign up for.

Already have a redacted PDF? Check if the redaction worked →

Redact a PDF in your browser

Search for text or a pattern (or pick a preset), or switch to Draw and mark regions on the page. Then press Redact. The sample is a fictional insurance claim.

Document:Sample claim form

Your file is processed in this tab and is not uploaded.

Presets
0 regions marked

Loading the sample…

Automate this

Redact something above and the code for exactly what you did appears here, in JavaScript, Python and curl.

What a redaction removes

A black box drawn over text doesn't remove it: the text stays in the file and can be copied or extracted. Forme removes the content itself.

  • Text and images under a region are removed from the page; the rest of the line doesn't move.
  • Lines, shapes and clipping paths are cut at the region's edges, so nothing of their shape remains inside it.
  • Matching text is removed from annotations, links, bookmarks and alternate text.
  • XMP metadata, embedded files and document JavaScript are removed, and the document information is replaced.
  • The output is a new file: earlier revisions and unused objects from the input are not carried over.
  • A black rectangle marks each redacted area.

Check a redacted PDF yourself

Selecting text in a viewer only checks what the page shows. Check the output with a tool other than the one that redacted it:

  1. Extract all the text with a separate tool, for example pdftotext redacted.pdf -, and search it for the redacted values.
  2. Check the document properties, bookmarks, comments and attachments.
  3. Confirm that values you didn't redact are still there, so you know the check itself works.

Check any redacted PDF in your browser → It works on files redacted with any tool.

The playground's own check uses pdf.js, a different parser from the engine. It only covers text pdf.js can extract, so a clean result is not proof that a redaction is secure.

Security boundaries

If Forme can't redact some content safely, it returns an error instead of a PDF. It doesn't return a partly redacted file. The playground shows these refusals as refusals.

Refused input

  • encrypted PDFs
  • form fields under a region or holding matching text
  • text, images or paths inside a form XObject under a region
  • an area painted with a tiling pattern under a region
  • text drawn with a Type3 font that may lie under a region
  • text used as a clipping path (rendering modes 4 to 7) under a region
  • a page whose rotation is not a multiple of 90, or that sets UserUnit, when it has a region

Limitations

Whole text runs
A text run is removed whole when any of its glyphs is under a region. If a match shares a run with other words, such as a label on the same line, those words go too. You can see this in the sample's Notes paragraph.
Images
An image under a region is removed whole, even where most of it lies outside the region. Text inside an image can't be searched: run OCR first, or draw a region over it.
Vector graphics
Paths under a region are cut at the region's edges. Curves in a cut path are redrawn as fine straight segments, within 0.05 pt.
Search needs a text mapping
Search finds text in fonts with a standard encoding or a ToUnicode map, which covers most generated PDFs. Text without one can't be found by search: redact it by coordinates.

The current list is on the redaction concepts page.

Tested and disclosed

39 security tests check redacted output with an independent byte-level scanner, not the engine's own parser. On every change, CI also redacts real PDFs from Chrome, ReportLab and macOS Quartz, by text and by region, and checks the output with two independent parsers, Poppler and pdf.js: the redacted values must be gone and the rest must still be there. Two redaction flaws were found and fixed, and disclosed as security advisories. Use 0.34.0 or later; if you redacted documents with an earlier version, regenerate them from the originals.

  • GHSA-c9p3-6mjx-rp9g (fixed in 0.33.0): Redacted content could remain recoverable in PDFs redacted by Forme.
  • GHSA-f54v-83wx-hmg2 (fixed in 0.34.0): Redacted content could remain on rotated or cropped pages, in vector graphics, and in tiling patterns.

Redact PDFs in Node.js, Python or with the API

The playground's “Automate this” panel writes the code for what you did. The same engine is available four ways:

JavaScript library

@formepdf/core redacts in Node.js, the browser or a worker. The file stays on your machine.

Redaction reference →

Self-hosted server

The formepdf/forme Docker image serves POST /v1/redact on your own infrastructure.

Self-hosting guide →

PDF redaction API

The same endpoint, hosted at api.formepdf.com, with presets and saved redaction templates.

Hosted redact docs →

Python

The formepdf SDK's redact() calls the hosted API or your own server.

API reference →

PDF redaction questions

Does the playground upload my PDF?
No. The file is read in your browser, redacted by the Forme engine compiled to WebAssembly in a Web Worker, and downloaded from your browser's memory. No document, filename, text or pattern is sent to a server, including to analytics.
Does Forme remove the text or just cover it?
It removes it. Text and images under a region are removed from the page, matching text is removed from annotations, links, bookmarks and alternate text, XMP metadata, embedded files and document JavaScript are removed, and the output is a new file without earlier revisions. A black rectangle then marks each redacted area.
What happens when Forme can't redact a document safely?
It returns an error instead of a PDF. Encrypted PDFs, form fields under a region, content inside a form XObject under a region, tiling patterns, Type3 fonts, clip-mode text, and pages with a rotation that isn't a multiple of 90 are refused rather than partly redacted.
Can I redact scanned documents?
Only by coordinates. An image under a region is removed whole, but text inside an image can't be searched: run OCR first, or draw regions over it.
Which version should I use?
0.34.0 or later. Output from earlier versions can still contain the redacted content: before 0.33.0 in any document, and in 0.33.0 on rotated or cropped pages and in vector graphics and tiling patterns. Both issues were disclosed as security advisories.
Can I redact from Python?
Yes, through the API: the Python SDK's redact() sends the PDF to the hosted API or to your own self-hosted Forme server. To redact without sending the file anywhere, use @formepdf/core in Node.js or in the browser.