Generate HTML tables from CSV or JSON data
Generate HTML tables instantly with our free online HTML table generator. This tool helps web developers and content creators create properly formatted HTML tables with customizable rows and columns. Simply configure your table parameters and get HTML code in real-time.
Generate HTML tables from CSV or JSON data. The output includes properly formatted table markup that you can use in your web pages.
HTML table generator creates properly structured HTML tables from data. Input data as CSV, JSON, or manually, and get clean, accessible HTML table markup with optional styling, headers, and attributes.
Parse input data into rows and columns, then generate HTML table structure: <table>, <thead> with <th> headers, <tbody> with <tr> rows and <td> cells. Add optional attributes like class, id, borders, and accessibility features.
Semantic structure: <table><thead><tr><th>...</th></tr></thead><tbody><tr><td>...</td></tr></tbody></table>. Accessibility: scope="col/row" on headers, caption element, summary attribute (deprecated). CSS styling preferred over HTML attributes (border, cellpadding).
Convert spreadsheet data to HTML tables.
CSV data → HTML tableCreate tables for technical documentation.
Generate HTML tables for email layouts.
Create data tables for Jekyll, Hugo sites.
function generateTable(data, headers, options = {}) {
const { className, id, border } = options;
let html = '<table';
if (className) html += ` class="${className}"`;
if (id) html += ` id="${id}"`;
if (border) html += ' border="1"';
html += '>\n';
// Headers
if (headers && headers.length) {
html += ' <thead>\n <tr>\n';
headers.forEach(header => {
html += ` <th scope="col">${escapeHtml(header)}</th>\n`;
});
html += ' </tr>\n </thead>\n';
}
// Body
html += ' <tbody>\n';
data.forEach(row => {
html += ' <tr>\n';
row.forEach(cell => {
html += ` <td>${escapeHtml(cell)}</td>\n`;
});
html += ' </tr>\n';
});
html += ' </tbody>\n</table>';
return html;
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Usage
const data = [
['Alice', '30', 'Engineer'],
['Bob', '25', 'Designer']
];
const headers = ['Name', 'Age', 'Role'];
generateTable(data, headers, { className: 'data-table' });Generates accessible HTML table with proper structure. Escapes content to prevent XSS.
Use HTML table generator when creating data tables from CSV/JSON, generating documentation tables, or building email templates.
CSS is preferred. Avoid deprecated attributes like border, cellpadding, bgcolor. Use CSS for styling: border-collapse, padding, background-color. HTML attributes may be needed for email clients.