CSV to Table Converter

CSV to Table Converter

Convert your CSV data into a beautiful, responsive HTML table. Paste your CSV data or upload a file to get started.

No file chosen

Processing CSV data…

Converted Table

`], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'exported-table.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); // Function to convert CSV to HTML table function convertCSVToTable(csvData, delimiter, hasHeader, tableStyle) { const rows = csvData.split('\n').filter(row => row.trim() !== ''); if (rows.length === 0) { throw new Error('CSV data is empty'); } let tableClass = ''; if (tableStyle === 'striped') { tableClass = 'class="striped-table"'; } else if (tableStyle === 'bordered') { tableClass = 'class="bordered-table"'; } let tableHTML = ``; // Process header row if needed if (hasHeader && rows.length > 0) { const headerCells = rows[0].split(delimiter); tableHTML += ''; for (const cell of headerCells) { tableHTML += ``; } tableHTML += ''; rows.shift(); // Remove header row from data } // Process data rows tableHTML += ''; for (const row of rows) { const cells = row.split(delimiter); tableHTML += ''; for (const cell of cells) { tableHTML += ``; } tableHTML += ''; } tableHTML += '
${escapeHTML(cell.trim())}
${escapeHTML(cell.trim())}
'; return tableHTML; } // Function to escape HTML special characters function escapeHTML(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } // Function to show error message function showError(message) { errorMessage.textContent = message; errorMessage.style.display = 'block'; } // Add some sample data on first load if (!csvTextarea.value) { csvTextarea.value = `Name,Age,City,Occupation John Doe,28,New York,Software Engineer Jane Smith,32,Los Angeles,Graphic Designer Robert Johnson,45,Chicago,Project Manager Emily Davis,29,Houston,Data Analyst Michael Brown,36,Miami,Marketing Specialist`; } });