JavaScript
Use TabularJS in vanilla JavaScript, no bundler required. Works in any modern browser or Node.js environment with a single function call.
Installation
Section titled “Installation”Install via npm:
npm install tabularjsOr load directly from a CDN, no build step needed:
<script src="https://cdn.jsdelivr.net/npm/tabularjs/dist/index.js"></script>Basic Example
Section titled “Basic Example”Listen for a file input change event and pass the selected file to tabularjs.
import tabularjs from 'tabularjs';
const input = document.getElementById('fileInput');
input.addEventListener('change', async (e) => { const file = e.target.files[0]; if (!file) return;
const result = await tabularjs(file); const [headers, ...rows] = result.worksheets[0].data;
console.log('Headers:', headers); console.log('Rows:', rows);});CDN Example
Section titled “CDN Example”A self-contained HTML page: drop it into any project without a build tool.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" /> <title>TabularJS CDN</title></head><body> <input type="file" id="fileInput" /> <pre id="output"></pre>
<script src="https://cdn.jsdelivr.net/npm/tabularjs/dist/index.js"></script> <script> document.getElementById('fileInput') .addEventListener('change', async (e) => { const file = e.target.files[0]; if (!file) return;
const result = await tabularjs(file); document.getElementById('output').textContent = JSON.stringify(result, null, 2); }); </script></body></html>Node.js
Section titled “Node.js”Read a file from disk with fs and parse it server-side.
import { readFile } from 'fs/promises';import tabularjs from 'tabularjs';
const buffer = await readFile('./data.xlsx');const result = await tabularjs(new Blob([buffer]));
const [headers, ...rows] = result.worksheets[0].data;console.log('Headers:', headers);console.log('Rows:', rows);
