Parse Document in n8n
PDF4me Parse Document runs your saved parse template against a PDF inside an n8n workflow and returns the extracted fields as structured data. Feed it binary data from a previous node, a Base64 string, or a public URL, reference the template by Parse ID, and pipe the resulting JSON, XML, or CSV straight into Set, IF, HTTP Request, or any downstream n8n node. The template carries the extraction logic, so the same node extracts invoices, contracts, receipts, and any custom layout you have configured.
Before you run this node: create a parse template in the PDF4me dashboard. Define your capture keys and pick Regex Expression for stable patterns or JavaScript Expression for conditional logic. The n8n node references that template by Parse ID. See Prepare Parse Info for Document for full setup, Regex examples (INV-\d{6,10}, \d{2}/\d{2}/\d{4}), and two working JavaScript Expression classifier samples.
Authenticating Your API Request
The PDF4me node in n8n requires PDF4me API credentials. Create the credential once in n8n with your API key from the dashboard, then reference it from every PDF4me node in your workflow.
Important Facts You Should Not Miss
text variable for classification and fallback rules.
Parameters
| Parameter | Required | What it does | Example |
|---|---|---|---|
| Input Data Type | Yes | How the PDF reaches the node. Binary Data (from a prior node), Base64 String (inline encoded), or URL (public file URL). | Binary Data |
| Input Binary Field | Conditional | Name of the binary field on the input item containing the PDF. Required when Input Data Type is Binary Data. | data |
| Base64 PDF Content | Conditional | Base64 encoded PDF content. Required when Input Data Type is Base64 String. No data: prefix. | JVBERi0xLjQK... |
| PDF URL | Conditional | Publicly reachable URL of the PDF. Required when Input Data Type is URL. The PDF4me service downloads and processes it. | https://example.com/invoice.pdf |
| Document Name | Yes | Source filename including .pdf extension. Used for format detection and error tracing. | invoice.pdf |
| Parse ID | Yes | TemplateId GUID from the PDF4me dashboard. Identifies the parse template (capture keys + extraction rules) to apply. | 12345678-1234-1234-1234-123456789abc |
| Output Format | Yes | Shape of the returned data. JSON (default, structured object), XML (hierarchical), or CSV (flat tabular). JSON is the right choice for almost every n8n workflow. | JSON |
| Output Binary Field Name | Yes | Name of the binary field the node attaches the parsed output to on the output item. Reference it from downstream nodes. | data |
| Custom Profiles | No | Advanced JSON-style overrides for parsing behaviour (output sub-format, include metadata flag, etc). Leave empty for default behaviour. | { "outputDataFormat": "json", "includeMetadata": true } |
Expression types in your parse template
The capture rules live in the template, not in the n8n node. Both expression types ship with every PDF4me account.
Regex ExpressionStable patternsINV-\d{6,10}), dates (\d{2}/\d{2}/\d{4}), amounts ($?\d{1,3}(?:,\d{3})*(?:.\d{2})?). Around 80% of production keys.JavaScript ExpressionConditional logic and classifierstext; return a string. Multi-marker classification, fallback rules, date normalization. See Prepare Parse Info for Document for two working samples.Output
| Field | Type | What it contains |
|---|---|---|
fileName | String | Generated output filename with timestamp and extension matching Output Format (.json / .xml / .csv). |
mimeType | String | MIME type of the output (application/json, application/xml, text/csv). |
fileSize | Number | Size of the parsed output in bytes. |
success | Boolean | true on a successful parse, false otherwise. Wire into an IF node for branching. |
message | String | Status message. Document parsed successfully on the happy path, or a descriptive error. |
docName | String | Original input filename, preserved for audit trails. |
The parsed key/value data itself lives on the binary field you named in Output Binary Field Name.
Workflow examples
Common n8n workflow patternsTypical ways to chain Parse Document into an n8n workflow.
- Gmail Trigger fires on new invoices labelled vendor-invoice.
- Filter passes only attachments ending in .pdf.
- Parse Document runs the Invoice template against the binary attachment.
- Set node maps parsed invoiceNumber, totalAmount, invoiceDate.
- Postgres Insert writes the row into the accounts_payable table.
- Webhook receives a PDF from a partner upload portal.
- Parse Document runs a template with a JavaScript Expression key returning the document type.
- Switch node routes on the returned type (invoice / order / receipt) to type-specific downstream branches.
- Each branch posts the parsed fields to the right destination system.
- Schedule trigger fires every 15 minutes.
- S3 List + Get Object loads each new PDF in the inbound bucket.
- Parse Document runs the template against each binary item.
- Airtable Create Record writes the parsed fields into the tracking base.