Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

n8n-nodes-csv-json-htmltable-converter

msoukhomlinov405MIT1.2.3TypeScript support: included

A comprehensive n8n node for seamless bidirectional conversion, replacement, and styling of HTML tables, CSV, and JSON formats. Features advanced table selection (including Table With Caption, Table Under Heading, Last Table), Style and Replace operations

n8n, n8n-node, n8n-community-node, table, html, csv, json, converter, style, replace, caption, heading, n8nObject, workflow, data transformation, web scraping

readme

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.

Buy Me A Coffee

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

  1. Add the "CSV JSON HTMLTable Converter" node to your workflow
  2. Select the operation: Convert, Replace, or Style
  3. Configure the source/target format, input data, and options as needed
  4. For advanced table selection, use presets or custom selectors
  5. Set the output field name
  6. 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 the json 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 to development to enable detailed logs.

License

MIT

Buy Me A Coffee

n8n is a fair-code licensed workflow automation platform.

changelog

Changelog

All notable changes to the n8n-nodes-csv-json-htmltable-converter package will be documented in this file.

[1.2.3] - 2025-05-29

Fixed

  • Table Under Heading: Now finds tables after a heading in document order, even if separated by other elements (e.g.,

    ,

    ), not just direct siblings.
  • Last Table preset: Now correctly returns the last table in the document, not the first.
  • Improved robustness for table selection presets and fixed edge cases with Cheerio selectors.

[1.2.2] - 2025-05-29

Fixed

  • Fixed various issues with Replace operations

[1.2.1] - 2025-05-29

Fixed

  • Reverted back to INodeTypeDescription version 1

[1.2.0] - 2025-05-29

Fixed

  • Corrected the version in the node file (was incorrectly set to 1 instead of 1.1), which caused issues with upgrading to the new version. No other changes.

[1.1.0] - 2025-05-28

Fixed

  • Corrected the version in the node file (was incorrectly set to 1 instead of 1.1), which caused issues with upgrading to the new version. No other changes.

[1.0.0] - 2025-05-28

Added

  • Style operation: Apply custom CSS classes, inline styles, zebra striping, border styles, caption styling, and more to HTML tables. Supports advanced table formatting for display, reports, and emails.
  • Replace operation: Replace an existing HTML table in a document with new content (HTML, CSV, or JSON). Supports all table selection presets and advanced selectors.
  • Advanced and preset table selection:
    • Table With Caption: Extract tables with a element, optionally filtered by caption text. Caption is included in JSON, as a comment in CSV, and as in HTML.
    • Table Under Heading: Now supports numeric heading level (1–999) and improved table index logic (only direct sibling tables after heading).
    • Last Table: Easily select the last table in a document.
    • Improved error messages and validation for all selection modes.
  • n8nObject output format: Directly outputs JavaScript objects for use in n8n workflows, with improved handling for single/multiple items and chaining between nodes.
  • Output field and format improvements:
    • Consistent output wrapping for all formats (HTML, CSV, JSON, n8nObject).
    • Improved handling of multiple tables/objects and output field naming.
  • UI/UX enhancements:
    • More intuitive parameter grouping and help text.
    • Improved validation and user feedback for invalid selectors, heading levels, and missing tables.
  • Debug logging: Optional debug logging for development and troubleshooting.

Changed

  • Improved table header handling: When 'Include Table Headers' is false, header rows are now fully excluded from output.
  • HTML to HTML conversion: Now processes and regenerates HTML tables for consistent formatting and escaping, rather than returning input as-is.
  • Chaining and n8n integration: Improved detection and handling of n8nObject input/output for seamless chaining between nodes.
  • Migrated from json2csv (now abandoned) to json-2-csv for JSON to CSV conversion. Maintained feature parity for delimiter, header, and field options. No breaking changes expected.
  • Upgraded to Cheerio 1.0+ for improved HTML parsing and selector support.

Fixed

  • Table index logic for Table Under Heading: Now only counts direct sibling tables after the heading, not all descendants.
  • Output field handling: Fixed issues with output field naming and wrapping for all formats.
  • Debug logging: Removed stray debug output from production builds.
  • Error handling: Improved error messages and validation for all operations and selection modes.

Breaking Changes

  • 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 Notes

  • 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.

[0.2.1] - 2025-04-24

Added

  • Added HTML Element Selector option to allow selecting specific parts of HTML documents for table extraction using Cheerio's CSS selector syntax
  • Added simplified HTML table selection mode with preset selectors for common scenarios
  • Added "Table Under Heading" preset to easily find tables that appear after specific headings, with option to select which table (1st-10th)
  • Added improved error messages with helpful suggestions for table selection
  • Added documentation and examples for using HTML table selectors effectively

Changed

  • Simplified input handling to only support direct manual input
  • Removed "Input Type" and "Input From Field" options
  • Updated "Input Data" field description for clarity
  • Updated documentation to reflect the simplified input method
  • Improved code structure and error handling
  • Updated package version
  • Minor code improvements and documentation updates

Features

  • Support for bidirectional conversion between HTML Tables, CSV, and JSON formats
  • Options for customizing conversion settings
  • Comprehensive input validation
  • Detailed error messages for troubleshooting