Nutrient Data Extraction API pulls tables out of PDFs and scans with their structure intact. It returns every table as JSON, with each cell’s row, column, merged-cell span, and position on the page. Need a spreadsheet? Nutrient DWS Processor API returns an Excel workbook ready for formulas.
Try it live
Pick a sample document, such as the invoice, and compare the extracted tables with the original page. To run it on your own PDF, open Parse Studio (a temporary workspace needs no signup).
The Processor API turns a PDF page into an Excel workbook, with rows and columns preserved. For code, ETL, and LLM pipelines, Nutrient’s Data Extraction API returns each table as JSON with merged-cell spans and a confidence score on every cell. Already using the Processor API’s JSON output? It keeps working.
The Data Extraction API marks header cells and records each cell’s row and column span, so a two-level header rebuilds exactly as printed. Rows that wrap onto several lines stay together as one row when detected, and the table’s caption and footnotes are linked to it by ID. Every cell carries a confidence score, so low-confidence cells can go to review before the data moves on.
Scanned and image-only PDFs go through OCR before the tables are read. In the Processor API, an OCR action in the same request runs before the Excel conversion, and the JSON output runs OCR as part of extraction. In the Data Extraction API, understand mode reads scanned tables with AI-augmented OCR.
Choose the output
Returns table elements with merged-cell spans, header flags, and a confidence score on every cell, from the Data Extraction API in understand mode. Save a PDF as document.pdf and run the sample from the same folder: Python and JavaScript print each table as rows, and curl saves the full response to result.json. Free plan: $5 of usage every month.
Returns tables with cells, header flags, positions, and the ruling lines drawn on the page. Add a PDF named document.pdf to your project folder, run the code from the same folder, and open result.json. Free plan: $5 of usage every month.
Get the Postman collectionReturns an XLSX workbook with rows and columns preserved. Add a PDF file named document.pdf to your project folder, run the code from the same folder, and open result.xlsx. Free plan: $5 of usage every month.
Explore the PDF-to-Excel APIcurl -X POST https://api.nutrient.io/extraction/parse \ -H "Authorization: Bearer your_api_key_goes_here" \ -F "file=@document.pdf" \ -F 'instructions={"mode":"understand","output":{"format":"spatial"}}' \ -o result.jsoncurl -X POST https://api.nutrient.io/extraction/parse ^ -H "Authorization: Bearer your_api_key_goes_here" ^ -F "file=@document.pdf" ^ -F "instructions={\"mode\":\"understand\",\"output\":{\"format\":\"spatial\"}}" ^ -o result.json// This code requires Node.js. Do not run this code directly in a web browser.import fs from "node:fs";
const form = new FormData();form.append("file", await fs.openAsBlob("document.pdf"), "document.pdf");form.append( "instructions", JSON.stringify({ mode: "understand", output: { format: "spatial" } }),);
const response = await fetch("https://api.nutrient.io/extraction/parse", { method: "POST", headers: { Authorization: "Bearer your_api_key_goes_here" }, body: form,});if (!response.ok) throw new Error(await response.text());
const { output } = await response.json();for (const table of output.elements.filter((el) => el.type === "table")) { // Rebuild the grid; a merged cell fills every row and column it spans. const grid = Array.from({ length: table.rowCount }, () => Array(table.columnCount).fill(""), ); for (const cell of table.cells) { for (let row = cell.row; row < cell.row + cell.rowSpan; row++) { for (let col = cell.column; col < cell.column + cell.colSpan; col++) { grid[row][col] = cell.text; } } } console.log(`Table on page ${table.page.pageNumber}:`); for (const row of grid) console.log(row.join(" | "));}import requests
response = requests.post( "https://api.nutrient.io/extraction/parse", headers={"Authorization": "Bearer your_api_key_goes_here"}, files={"file": open("document.pdf", "rb")}, data={ "instructions": '{"mode":"understand","output":{"format":"spatial"}}' },)response.raise_for_status()
for element in response.json()["output"]["elements"]: if element["type"] != "table": continue # Rebuild the grid; a merged cell fills every row and column it spans. grid = [[""] * element["columnCount"] for _ in range(element["rowCount"])] for cell in element["cells"]: for row in range(cell["row"], cell["row"] + cell["rowSpan"]): for col in range(cell["column"], cell["column"] + cell["colSpan"]): grid[row][col] = cell["text"] print(f'Table on page {element["page"]["pageNumber"]}:') for row in grid: print(" | ".join(row)){ "status": 200, "requestId": "GNzb_SMyMVD5MS8AAoBB", "output": { "elements": [ { "type": "table", "confidence": 0.99, "readingOrder": 3, "bounds": { "x": 92, "y": 301, "width": 749, "height": 391 }, "page": { "pageIndex": 0, "pageNumber": 1 }, "rowCount": 6, "columnCount": 4, "cells": [ { "row": 0, "column": 0, "rowSpan": 2, "colSpan": 1, "isHeader": true, "text": "Region", "confidence": 1, "bounds": { "x": 145, "y": 335, "width": 137, "height": 56 } }, { "row": 0, "column": 1, "rowSpan": 1, "colSpan": 2, "isHeader": true, "text": "Q3 2026", "confidence": 1, "bounds": { "x": 426, "y": 308, "width": 217, "height": 54 } }, { "row": 2, "column": 0, "rowSpan": 1, "colSpan": 1, "text": "North America", "confidence": 1, "bounds": { "x": 98, "y": 437, "width": 234, "height": 52 } }, { "row": 2, "column": 1, "rowSpan": 1, "colSpan": 1, "text": "12,400.00", "confidence": 1, "bounds": { "x": 337, "y": 437, "width": 165, "height": 54 } } ], "captionIds": ["acef2236-5a74-4e5e-a889-7fe89e4d3817"], "footnoteIds": ["99968e0f-917a-4388-a77d-5ad9ec590091"] } ] }, "configuration": { "mode": "understand", "outputFormat": "spatial" }}curl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.json \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.json ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"json-content\", \"plainText\": false, \"structuredText\": false, \"keyValuePairs\": false, \"tables\": true}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "json-content") .put("plainText", false) .put("structuredText", false) .put("keyValuePairs", false) .put("tables", true) ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.json"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "json-content", ["plainText"] = false, ["structuredText"] = false, ["keyValuePairs"] = false, ["tables"] = true } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.json"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "json-content", plainText: false, structuredText: false, keyValuePairs: false, tables: true }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.json")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'json-content', 'plainText': False, 'structuredText': False, 'keyValuePairs': False, 'tables': True } }) }, stream = True)
if response.ok: with open('result.json', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.json', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--{ "pages": [ { "pageIndex": 0, "tables": [ { "confidence": 95.4, "bbox": { "left": 92, "top": 301, "width": 749, "height": 391 }, "cells": [ { "bbox": { "left": 145, "top": 335, "width": 137, "height": 56 }, "rowIndex": 0, "columnIndex": 0, "isHeader": true, "text": "Region" } ], "columns": [{ "bbox": { "left": 92, "top": 301, "width": 190, "height": 391 } }], "rows": [{ "bbox": { "left": 92, "top": 301, "width": 749, "height": 56 } }], "lines": [ { "bbox": { "left": 92, "top": 301, "width": 749, "height": 1 }, "isVertical": false, "thickness": 1 } ] } ] } ]}curl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.xlsx \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.xlsx ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"xlsx\"}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "xlsx") ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.xlsx"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "xlsx" } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.xlsx"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "xlsx" }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.xlsx")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'xlsx' } }) }, stream = True)
if response.ok: with open('result.xlsx', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.xlsx', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--curl -X POST https://api.nutrient.io/extraction/parse \ -H "Authorization: Bearer your_api_key_goes_here" \ -F "file=@document.pdf" \ -F 'instructions={"mode":"understand","output":{"format":"spatial"}}' \ -o result.jsoncurl -X POST https://api.nutrient.io/extraction/parse ^ -H "Authorization: Bearer your_api_key_goes_here" ^ -F "file=@document.pdf" ^ -F "instructions={\"mode\":\"understand\",\"output\":{\"format\":\"spatial\"}}" ^ -o result.json// This code requires Node.js. Do not run this code directly in a web browser.import fs from "node:fs";
const form = new FormData();form.append("file", await fs.openAsBlob("document.pdf"), "document.pdf");form.append( "instructions", JSON.stringify({ mode: "understand", output: { format: "spatial" } }),);
const response = await fetch("https://api.nutrient.io/extraction/parse", { method: "POST", headers: { Authorization: "Bearer your_api_key_goes_here" }, body: form,});if (!response.ok) throw new Error(await response.text());
const { output } = await response.json();for (const table of output.elements.filter((el) => el.type === "table")) { // Rebuild the grid; a merged cell fills every row and column it spans. const grid = Array.from({ length: table.rowCount }, () => Array(table.columnCount).fill(""), ); for (const cell of table.cells) { for (let row = cell.row; row < cell.row + cell.rowSpan; row++) { for (let col = cell.column; col < cell.column + cell.colSpan; col++) { grid[row][col] = cell.text; } } } console.log(`Table on page ${table.page.pageNumber}:`); for (const row of grid) console.log(row.join(" | "));}import requests
response = requests.post( "https://api.nutrient.io/extraction/parse", headers={"Authorization": "Bearer your_api_key_goes_here"}, files={"file": open("document.pdf", "rb")}, data={ "instructions": '{"mode":"understand","output":{"format":"spatial"}}' },)response.raise_for_status()
for element in response.json()["output"]["elements"]: if element["type"] != "table": continue # Rebuild the grid; a merged cell fills every row and column it spans. grid = [[""] * element["columnCount"] for _ in range(element["rowCount"])] for cell in element["cells"]: for row in range(cell["row"], cell["row"] + cell["rowSpan"]): for col in range(cell["column"], cell["column"] + cell["colSpan"]): grid[row][col] = cell["text"] print(f'Table on page {element["page"]["pageNumber"]}:') for row in grid: print(" | ".join(row)){ "status": 200, "requestId": "GNzb_SMyMVD5MS8AAoBB", "output": { "elements": [ { "type": "table", "confidence": 0.99, "readingOrder": 3, "bounds": { "x": 92, "y": 301, "width": 749, "height": 391 }, "page": { "pageIndex": 0, "pageNumber": 1 }, "rowCount": 6, "columnCount": 4, "cells": [ { "row": 0, "column": 0, "rowSpan": 2, "colSpan": 1, "isHeader": true, "text": "Region", "confidence": 1, "bounds": { "x": 145, "y": 335, "width": 137, "height": 56 } }, { "row": 0, "column": 1, "rowSpan": 1, "colSpan": 2, "isHeader": true, "text": "Q3 2026", "confidence": 1, "bounds": { "x": 426, "y": 308, "width": 217, "height": 54 } }, { "row": 2, "column": 0, "rowSpan": 1, "colSpan": 1, "text": "North America", "confidence": 1, "bounds": { "x": 98, "y": 437, "width": 234, "height": 52 } }, { "row": 2, "column": 1, "rowSpan": 1, "colSpan": 1, "text": "12,400.00", "confidence": 1, "bounds": { "x": 337, "y": 437, "width": 165, "height": 54 } } ], "captionIds": ["acef2236-5a74-4e5e-a889-7fe89e4d3817"], "footnoteIds": ["99968e0f-917a-4388-a77d-5ad9ec590091"] } ] }, "configuration": { "mode": "understand", "outputFormat": "spatial" }}curl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.json \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.json ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"json-content\", \"plainText\": false, \"structuredText\": false, \"keyValuePairs\": false, \"tables\": true}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "json-content") .put("plainText", false) .put("structuredText", false) .put("keyValuePairs", false) .put("tables", true) ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.json"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "json-content", ["plainText"] = false, ["structuredText"] = false, ["keyValuePairs"] = false, ["tables"] = true } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.json"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "json-content", plainText: false, structuredText: false, keyValuePairs: false, tables: true }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.json")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'json-content', 'plainText': False, 'structuredText': False, 'keyValuePairs': False, 'tables': True } }) }, stream = True)
if response.ok: with open('result.json', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.json', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--{ "pages": [ { "pageIndex": 0, "tables": [ { "confidence": 95.4, "bbox": { "left": 92, "top": 301, "width": 749, "height": 391 }, "cells": [ { "bbox": { "left": 145, "top": 335, "width": 137, "height": 56 }, "rowIndex": 0, "columnIndex": 0, "isHeader": true, "text": "Region" } ], "columns": [{ "bbox": { "left": 92, "top": 301, "width": 190, "height": 391 } }], "rows": [{ "bbox": { "left": 92, "top": 301, "width": 749, "height": 56 } }], "lines": [ { "bbox": { "left": 92, "top": 301, "width": 749, "height": 1 }, "isVertical": false, "thickness": 1 } ] } ] } ]}curl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.xlsx \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.xlsx ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"xlsx\"}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "xlsx") ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.xlsx"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "xlsx" } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.xlsx"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "xlsx" }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.xlsx")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'xlsx' } }) }, stream = True)
if response.ok: with open('result.xlsx', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.xlsx', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--Returns table elements with merged-cell spans, header flags, and a confidence score on every cell, from the Data Extraction API in understand mode. Save a PDF as document.pdf and run the sample from the same folder: Python and JavaScript print each table as rows, and curl saves the full response to result.json. Free plan: $5 of usage every month.
Returns tables with cells, header flags, positions, and the ruling lines drawn on the page. Add a PDF named document.pdf to your project folder, run the code from the same folder, and open result.json. Free plan: $5 of usage every month.
Get the Postman collectionReturns an XLSX workbook with rows and columns preserved. Add a PDF file named document.pdf to your project folder, run the code from the same folder, and open result.xlsx. Free plan: $5 of usage every month.
Explore the PDF-to-Excel API01
Returns table elements with merged-cell spans, header flags, and a confidence score on every cell, from the Data Extraction API in understand mode. Save a PDF as document.pdf and run the sample from the same folder: Python and JavaScript print each table as rows, and curl saves the full response to result.json. Free plan: $5 of usage every month.
curl -X POST https://api.nutrient.io/extraction/parse \ -H "Authorization: Bearer your_api_key_goes_here" \ -F "file=@document.pdf" \ -F 'instructions={"mode":"understand","output":{"format":"spatial"}}' \ -o result.jsoncurl -X POST https://api.nutrient.io/extraction/parse ^ -H "Authorization: Bearer your_api_key_goes_here" ^ -F "file=@document.pdf" ^ -F "instructions={\"mode\":\"understand\",\"output\":{\"format\":\"spatial\"}}" ^ -o result.json// This code requires Node.js. Do not run this code directly in a web browser.import fs from "node:fs";
const form = new FormData();form.append("file", await fs.openAsBlob("document.pdf"), "document.pdf");form.append( "instructions", JSON.stringify({ mode: "understand", output: { format: "spatial" } }),);
const response = await fetch("https://api.nutrient.io/extraction/parse", { method: "POST", headers: { Authorization: "Bearer your_api_key_goes_here" }, body: form,});if (!response.ok) throw new Error(await response.text());
const { output } = await response.json();for (const table of output.elements.filter((el) => el.type === "table")) { // Rebuild the grid; a merged cell fills every row and column it spans. const grid = Array.from({ length: table.rowCount }, () => Array(table.columnCount).fill(""), ); for (const cell of table.cells) { for (let row = cell.row; row < cell.row + cell.rowSpan; row++) { for (let col = cell.column; col < cell.column + cell.colSpan; col++) { grid[row][col] = cell.text; } } } console.log(`Table on page ${table.page.pageNumber}:`); for (const row of grid) console.log(row.join(" | "));}import requests
response = requests.post( "https://api.nutrient.io/extraction/parse", headers={"Authorization": "Bearer your_api_key_goes_here"}, files={"file": open("document.pdf", "rb")}, data={ "instructions": '{"mode":"understand","output":{"format":"spatial"}}' },)response.raise_for_status()
for element in response.json()["output"]["elements"]: if element["type"] != "table": continue # Rebuild the grid; a merged cell fills every row and column it spans. grid = [[""] * element["columnCount"] for _ in range(element["rowCount"])] for cell in element["cells"]: for row in range(cell["row"], cell["row"] + cell["rowSpan"]): for col in range(cell["column"], cell["column"] + cell["colSpan"]): grid[row][col] = cell["text"] print(f'Table on page {element["page"]["pageNumber"]}:') for row in grid: print(" | ".join(row)){ "status": 200, "requestId": "GNzb_SMyMVD5MS8AAoBB", "output": { "elements": [ { "type": "table", "confidence": 0.99, "readingOrder": 3, "bounds": { "x": 92, "y": 301, "width": 749, "height": 391 }, "page": { "pageIndex": 0, "pageNumber": 1 }, "rowCount": 6, "columnCount": 4, "cells": [ { "row": 0, "column": 0, "rowSpan": 2, "colSpan": 1, "isHeader": true, "text": "Region", "confidence": 1, "bounds": { "x": 145, "y": 335, "width": 137, "height": 56 } }, { "row": 0, "column": 1, "rowSpan": 1, "colSpan": 2, "isHeader": true, "text": "Q3 2026", "confidence": 1, "bounds": { "x": 426, "y": 308, "width": 217, "height": 54 } }, { "row": 2, "column": 0, "rowSpan": 1, "colSpan": 1, "text": "North America", "confidence": 1, "bounds": { "x": 98, "y": 437, "width": 234, "height": 52 } }, { "row": 2, "column": 1, "rowSpan": 1, "colSpan": 1, "text": "12,400.00", "confidence": 1, "bounds": { "x": 337, "y": 437, "width": 165, "height": 54 } } ], "captionIds": ["acef2236-5a74-4e5e-a889-7fe89e4d3817"], "footnoteIds": ["99968e0f-917a-4388-a77d-5ad9ec590091"] } ] }, "configuration": { "mode": "understand", "outputFormat": "spatial" }}02
Returns tables with cells, header flags, positions, and the ruling lines drawn on the page. Add a PDF named document.pdf to your project folder, run the code from the same folder, and open result.json. Free plan: $5 of usage every month.
Get the Postman collectioncurl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.json \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.json ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"json-content\", \"plainText\": false, \"structuredText\": false, \"keyValuePairs\": false, \"tables\": true}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "json-content") .put("plainText", false) .put("structuredText", false) .put("keyValuePairs", false) .put("tables", true) ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.json"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "json-content", ["plainText"] = false, ["structuredText"] = false, ["keyValuePairs"] = false, ["tables"] = true } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.json"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "json-content", plainText: false, structuredText: false, keyValuePairs: false, tables: true }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.json")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'json-content', 'plainText': False, 'structuredText': False, 'keyValuePairs': False, 'tables': True } }) }, stream = True)
if response.ok: with open('result.json', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.json', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "json-content", "plainText": false, "structuredText": false, "keyValuePairs": false, "tables": true }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--{ "pages": [ { "pageIndex": 0, "tables": [ { "confidence": 95.4, "bbox": { "left": 92, "top": 301, "width": 749, "height": 391 }, "cells": [ { "bbox": { "left": 145, "top": 335, "width": 137, "height": 56 }, "rowIndex": 0, "columnIndex": 0, "isHeader": true, "text": "Region" } ], "columns": [{ "bbox": { "left": 92, "top": 301, "width": 190, "height": 391 } }], "rows": [{ "bbox": { "left": 92, "top": 301, "width": 749, "height": 56 } }], "lines": [ { "bbox": { "left": 92, "top": 301, "width": 749, "height": 1 }, "isVertical": false, "thickness": 1 } ] } ] } ]}03
Returns an XLSX workbook with rows and columns preserved. Add a PDF file named document.pdf to your project folder, run the code from the same folder, and open result.xlsx. Free plan: $5 of usage every month.
Explore the PDF-to-Excel APIcurl -X POST https://api.nutrient.io/build \ -H "Authorization: Bearer your_api_key_here" \ -o result.xlsx \ --fail \ -F document=@document.pdf \ -F instructions='{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }'curl -X POST https://api.nutrient.io/build ^ -H "Authorization: Bearer your_api_key_here" ^ -o result.xlsx ^ --fail ^ -F document=@document.pdf ^ -F instructions="{\"parts\": [{\"file\": \"document\"}], \"output\": {\"type\": \"xlsx\"}}"package com.example.pspdfkit;
import java.io.File;import java.io.IOException;import java.nio.file.FileSystems;import java.nio.file.Files;import java.nio.file.StandardCopyOption;
import org.json.JSONArray;import org.json.JSONObject;
import okhttp3.MediaType;import okhttp3.MultipartBody;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.RequestBody;import okhttp3.Response;
public final class PspdfkitApiExample { public static void main(final String[] args) throws IOException { final RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart( "document", "document.pdf", RequestBody.create( MediaType.parse("application/pdf"), new File("document.pdf") ) ) .addFormDataPart( "instructions", new JSONObject() .put("parts", new JSONArray() .put(new JSONObject() .put("file", "document") ) ) .put("output", new JSONObject() .put("type", "xlsx") ).toString() ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/build") .method("POST", body) .addHeader("Authorization", "Bearer your_api_key_here") .build();
final OkHttpClient client = new OkHttpClient() .newBuilder() .build();
final Response response = client.newCall(request).execute();
if (response.isSuccessful()) { Files.copy( response.body().byteStream(), FileSystems.getDefault().getPath("result.xlsx"), StandardCopyOption.REPLACE_EXISTING ); } else { // Handle the error throw new IOException(response.body().string()); } }}using System;using System.IO;using System.Net;using RestSharp;
namespace PspdfkitApiDemo{ class Program { static void Main(string[] args) { var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer your_api_key_here") .AddFile("document", "document.pdf") .AddParameter("instructions", new JsonObject { ["parts"] = new JsonArray { new JsonObject { ["file"] = "document" } }, ["output"] = new JsonObject { ["type"] = "xlsx" } }.ToString());
request.AdvancedResponseWriter = (responseStream, response) => { if (response.StatusCode == HttpStatusCode.OK) { using (responseStream) { using var outputFileWriter = File.OpenWrite("result.xlsx"); responseStream.CopyTo(outputFileWriter); } } else { var responseStreamReader = new StreamReader(responseStream); Console.Write(responseStreamReader.ReadToEnd()); } };
client.Execute(request); } }}// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require('axios')const FormData = require('form-data')const fs = require('fs')
const formData = new FormData()formData.append('instructions', JSON.stringify({ parts: [ { file: "document" } ], output: { type: "xlsx" }}))formData.append('document', fs.createReadStream('document.pdf'))
;(async () => { try { const response = await axios.post('https://api.nutrient.io/build', formData, { headers: formData.getHeaders({ 'Authorization': 'Bearer your_api_key_here' }), responseType: "stream" })
response.data.pipe(fs.createWriteStream("result.xlsx")) } catch (e) { const errorString = await streamToString(e.response.data) console.log(errorString) }})()
function streamToString(stream) { const chunks = [] return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))) stream.on("error", (err) => reject(err)) stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))) })}import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/build', headers = { 'Authorization': 'Bearer your_api_key_here' }, files = { 'document': open('document.pdf', 'rb') }, data = { 'instructions': json.dumps({ 'parts': [ { 'file': 'document' } ], 'output': { 'type': 'xlsx' } }) }, stream = True)
if response.ok: with open('result.xlsx', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()<?php
$FileHandle = fopen('result.xlsx', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/build', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'instructions' => '{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" } }', 'document' => new CURLFILE('document.pdf') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer your_api_key_here' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);POST https://api.nutrient.io/build HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer your_api_key_here
--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "document" } ], "output": { "type": "xlsx" }}--customboundaryContent-Disposition: form-data; name="document"; filename="document.pdf"Content-Type: application/pdf
(document data)--customboundary--Three steps
Every route takes a PDF and returns its tables in one request.
Sign up for a free Nutrient account and copy an API key from the dashboard. New accounts start free with $5 of usage every month, with no credit card required. The same balance covers the Data Extraction API and the Processor API, which runs Excel and Processor JSON.
Choose Excel for a spreadsheet, Processor JSON for tables alongside the page text, or Data Extraction JSON for merged cells, confidence scores, and Markdown output.
Send one REST request with the PDF. Excel comes back as an XLSX file; JSON comes back with each table’s rows, columns, and cells.
Request Markdown output from the Data Extraction API, and tables come back as HTML tables inside the Markdown, with merged cells kept as rowspan and colspan. The result is ready for an LLM prompt, a RAG index, a knowledge base, or as context for agents, without a conversion step.
The text mode ($0.001/page) reads born-digital PDFs without OCR and returns plain text only, no table elements. The structure mode ($0.0015/page) adds OCR but can miss complex table structure. The understand mode ($0.009/page) is recommended for tables. See processing modes for how to choose.
Every example on this page includes a Python tab, so table extraction drops into a Python service using the standard requests library, with no SDK to install. Teams that need table extraction to run on their own infrastructure rather than the cloud API can use the Python SDK for PDF table extraction instead.
Nutrient’s infrastructure is SOC 2 Type 2 audited and GDPR compliant. See our privacy policy and security documentation for details on data handling.
All communication between your application and Nutrient is done via HTTPS to ensure your data is encrypted when it’s sent to us.
All payments are handled by Paddle. Nutrient DWS Processor API never has direct access to any of your payment data.
Most common next steps
Related APIs:
Get started:
Platform resources:
PDF table extraction finds the tables in a document and returns their rows, columns, and cells as structured data, instead of a flat run of text. Nutrient offers two kinds. The Processor API converts PDF tables into an Excel (XLSX) workbook or returns them as JSON with cells, header flags, and positions. The Data Extraction API returns each table as a structured element with rows, columns, cells, merged-cell spans, coordinates, and confidence scores, for code, ETL, and LLM pipelines.
Nutrient extracts PDF tables to Excel (XLSX) and JSON with the Processor API, and to JSON and Markdown with the Data Extraction API. CSV and XML output are in development. If you’re interested, join the waitlist on the PDF-to-CSV and PDF-to-XML pages.
Nutrient’s table extraction API does it in one REST request. Send the PDF to the Processor API over REST and request the structured output you need. Ready-to-use examples are available in JavaScript, Python, Java, PHP, and HTTP (curl) to get a first request running quickly. For merged cells and a confidence score on every cell, send it to the Data Extraction API’s /extraction/parse endpoint in understand mode instead.
Yes. Nutrient’s Processor API converts PDF tables to Excel. The PDF-to-Excel API output returns an XLSX file with rows and columns preserved, ready for spreadsheets, reporting, and further processing.
Yes. Nutrient runs OCR on scanned tables before reading them. In the Processor API, add an OCR action to the request so the text in page images is recognized before the tables convert to Excel; the JSON output runs OCR as part of extraction. The Data Extraction API runs OCR in understand mode and returns scanned tables as table elements, with a confidence score for each cell.
Open source tools need more setup: Tabula reads only PDFs that already have a text layer, and Camelot’s built-in parsers need a text layer too, with scans handled only through an optional OCR add-on.
Yes. Nutrient’s Data Extraction API returns each cell with rowSpan and colSpan values and flags header cells with isHeader, so merged cells and two-level headers rebuild as printed. Each table links to its caption and footnotes through captionIds and footnoteIds, and rows that wrap onto several lines are kept together as one row when detected.
No. Extraction runs server-side through the cloud API with no Microsoft Office license or local install required, so it fits headless and containerized workflows.
Yes. Nutrient’s free plan includes $5 of usage every month with no credit card required, and understand mode, which is recommended for tables, costs $0.009 per page. Excel and Processor JSON run on the Processor API, paid from the same balance at its own rates. See API pricing and API pricing for details.
Create an account to get your Data Extraction API key and start making API calls.