n8n-nodes-csv-json-htmltable-converter
This is an n8n community node that provides seamless bidirectional conversion between HTML tables, CSV, and JSON formats, with advanced table selection, replacement, and styling features.
Key Features
- Convert between HTML Tables, CSV, and JSON formats
- Style HTML tables with custom CSS, zebra striping, borders, and captions
- Replace HTML tables with new content (HTML, CSV, or JSON)
- Advanced table selection presets:
- All Tables, First Table, Last Table
- Table With Caption (optionally filter by caption text)
- Table Under Heading (numeric heading level, improved index logic)
- Custom selectors (Cheerio CSS syntax)
- n8nObject output for direct workflow integration
- Comprehensive input validation and error messages
- UI/UX enhancements for easier configuration
- Debug logging for development/troubleshooting
Installation
Follow these instructions to install this node for your n8n instance:
npm install n8n-nodes-csv-json-htmltable-converter
Usage
- Add the "CSV JSON HTMLTable Converter" node to your workflow
- Select the operation: Convert, Replace, or Style
- Configure the source/target format, input data, and options as needed
- For advanced table selection, use presets or custom selectors
- Set the output field name
- Run the workflow to process your data
Operations
Convert
Transform data between HTML, CSV, and JSON formats. Use advanced table selection presets or custom selectors for precise extraction.
Replace
Replace an existing HTML table in a document with new content (HTML, CSV, or JSON). Supports all table selection presets and advanced selectors.
Style
Apply custom styles to HTML tables, including CSS classes, inline styles, zebra striping, border styles, caption styling, and more. Ideal for preparing tables for display, reports, or emails.
Style Operation Parameters
- HTML Input: The HTML string containing the table(s) to style
- Table Class: CSS class to add to
<table>
- Table Style: Inline CSS for
<table>
- Row Style: Inline CSS for
<tr>
(optional) - Cell Style: Inline CSS for
<td>/<th>
(optional) - Zebra Striping: Enable/disable alternating row colours
- Even Row Colour: Background colour for even rows (if zebra striping enabled)
- Odd Row Colour: Background colour for odd rows (if zebra striping enabled)
- Border Style: Border style for
<table>
(e.g. solid, dashed, none) - Border Width: Border width for
<table>
(e.g. 1px, 2px) - Caption Style: Inline CSS for
<caption>
(optional) - Caption Position: Position of the
<caption>
(top or bottom) - Output Field: The name of the output field to store the styled HTML (default:
styledHtml
)
Example: Styling an HTML Table
Input HTML:
<table>
<caption>Monthly Sales</caption>
<tr><th>Month</th><th>Sales</th></tr>
<tr><td>January</td><td>100</td></tr>
<tr><td>February</td><td>120</td></tr>
</table>
Style Operation Parameters:
- Table Class:
my-table
- Table Style:
width: 100%; border-collapse: collapse;
- Row Style:
font-size: 16px;
- Cell Style:
padding: 8px;
- Zebra Striping:
true
- Even Row Colour:
#f2f2f2
- Odd Row Colour:
#ffffff
- Border Style:
solid
- Border Width:
1px
- Caption Style:
font-weight: bold; color: #333;
- Caption Position:
top
Output HTML:
<table class="my-table" style="width: 100%; border-collapse: collapse; border-style: solid; border-width: 1px;">
<caption style="font-weight: bold; color: #333; caption-side: top;">Monthly Sales</caption>
<tr style="font-size: 16px;">
<th style="padding: 8px; border-style: solid; border-width: 1px;">Month</th>
<th style="padding: 8px; border-style: solid; border-width: 1px;">Sales</th>
</tr>
<tr style="font-size: 16px; background-color: #f2f2f2;">
<td style="padding: 8px; border-style: solid; border-width: 1px;">January</td>
<td style="padding: 8px; border-style: solid; border-width: 1px;">100</td>
</tr>
<tr style="font-size: 16px; background-color: #ffffff;">
<td style="padding: 8px; border-style: solid; border-width: 1px;">February</td>
<td style="padding: 8px; border-style: solid; border-width: 1px;">120</td>
</tr>
</table>
Table Selection Presets
- All Tables: Finds all table elements in the document
- First Table Only: Finds only the first table in the document
- Last Table: Finds the last table in the document
- Table With Caption: Finds a table with a element, optionally filtered by caption text. Caption is included in output (JSON, CSV, HTML).
- Table Under Heading: Finds a table after a heading of a specific numeric level (1–999) and (optionally) containing specific text. Table index logic only counts direct sibling tables after the heading.
- Custom: Use your own custom selector (for advanced users)
Output and n8nObject Format
- n8nObject output: Directly outputs JavaScript objects for use in n8n workflows. Single-item arrays are unwrapped; multi-item arrays are wrapped in the output field.
- Output field: All results are wrapped in the specified output field (default:
convertedData
), except for n8nObject output, which is always in thejson
property. - Chaining: Improved detection and handling of n8nObject input/output for seamless chaining between nodes.
Breaking Changes and Migration Notes
- Removed deprecated presets: 'Tables With Headers', 'Tables in Main Content', and 'Data Tables' presets have been removed. Use supported presets instead.
- Table Under Heading: Heading level is now a numeric input (1–999). Table index logic only counts direct sibling tables after the heading.
- Output format changes: Output wrapping and field naming are now consistent across all formats. n8nObject output is always in the 'json' property.
- Migration: Review your workflows for use of removed presets and update to supported options. If using Table Under Heading, ensure headingLevel and tableIndex parameters are set correctly. Review output field usage and update downstream nodes if needed.
Debug Logging
- Optional debug logging is available for development and troubleshooting. Set
NODE_ENV
todevelopment
to enable detailed logs.
License
n8n is a fair-code licensed workflow automation platform.