Skip to content

DOCX Extraction

Agent Mask extracts text from DOCX files, detects configured entities, and returns de-identified extracted text from a single mask() call. DOCX support is text extraction and de-identification, not Word file redaction: DOCX inputs do not return an edited or redacted .docx binary.

Use DOCX extraction when you need de-identified text from Word documents for analytics, QA, review, search, or downstream AI workflows and do not need to preserve the original Word layout.

DOCX bytes must be base64-encoded and zlib-compressed before passing them to mask().

SELECT app_public.mask(
'<compressed_base64_docx>',
OBJECT_CONSTRUCT(
'document_extraction_mode', 'simple'
)
);

The response includes:

  • columns[0].deidentified_text - de-identified extracted text.
  • columns[0].original_text - extracted source text before replacement.
  • columns[0].document_metadata.file_type - docx.

original_text can contain sensitive source values. Use include_analyzer_results=false and include_entity_ledger=false when you only need the de-identified text output and want to reduce response detail.

Use simple extraction for fast flat text output. Use structured extraction when tables, headings, and list structure matter in the returned text:

OBJECT_CONSTRUCT(
'document_extraction_mode', 'structured',
'structured_output_format', 'markdown'
)
  • "simple" — flat text, fastest, default.
  • "structured" — exports de-identified structured text as markdown, HTML, plain text, or JSON.

structured_output_format options are "markdown" (default), "html", "text", and "json".

Detected entities in the extracted DOCX text are replaced with the value selected by your operator configuration, such as [PERSON_1], [REDACTED], a hash, an encrypted value, or a faker value. The same language, entity, custom entity, and operator settings used for plain text apply to DOCX extraction.

Values that are not detected remain in the extracted output. Values handled with the keep operator also remain visible because keep reports detections without changing the text.

  • faker and encrypt produce variable-length replacements that may alter line lengths.
  • type_numbered produces consistent placeholders across all occurrences.
  • entity_type removes per-entity identity labels, but readers may still be able to count visible replacement occurrences.

DOCX extraction returns text, not a replacement Word document. Fonts, images, comments, tracked changes, headers, footers, exact pagination, and other Word layout details are not preserved as a redacted .docx file.

Extraction quality depends on the document structure, embedded content, language, and configured entities. Review representative outputs before external sharing, regulated disclosure, or public release.