DocSplitter is a command-line tool for splitting structured DOCX and PDF documents into smaller files using their headings. It can inspect a document's heading hierarchy, preview the output plan, and create the planned files without modifying the input document.
The npm package installs the doc-splitter command.
- Node.js 24
Install DocSplitter globally:
npm install --global @polishedapps/doc-splitterYou can also run it without a global installation:
npx @polishedapps/doc-splitter --helpInspect the heading hierarchy:
doc-splitter inspect "manual.docx"Preview the files that would be created:
doc-splitter plan "manual.docx" --level 2Split a document:
doc-splitter "manual.docx" --output "./output"Splitting is the default workflow, so there is no split command word. Before writing files, DocSplitter displays the planned filenames and asks for confirmation. Pass --yes to confirm without prompting.
| Command | Description |
|---|---|
doc-splitter inspect <input> |
Display the heading hierarchy of a DOCX or PDF document. |
doc-splitter plan <input> |
Calculate output paths and document ranges without creating files. |
doc-splitter <input> |
Preview and create the split output files. |
| Option | Description |
|---|---|
--level <number> |
Split at the selected heading level. |
--parent-headings <none|filename|folders> |
Include parent headings in filenames or folders. |
--index / --no-index |
Include or omit indexes in output filenames. |
--multilevel-index |
Use hierarchical filename indexes. |
--original-name |
Prefix output filenames with the input filename. |
--title-case / --no-title-case |
Transform or preserve heading-name casing. |
--json |
Write one versioned JSON result. |
--quiet |
Suppress progress and nonessential human-readable output. |
The split workflow also supports:
| Option | Description |
|---|---|
--output <directory> |
Select the output directory. The current directory is used by default. |
--subfolder |
Create a unique source-named subfolder under the output directory. |
--yes |
Create the planned files without prompting for confirmation. |
JSON split execution requires --yes:
doc-splitter "manual.pdf" --output "./output" --subfolder --json --yesRun the built-in help for the complete command reference:
doc-splitter --help
doc-splitter inspect --help
doc-splitter plan --help