{"id":13456550,"url":"https://github.com/lightswitch05/table-to-json","last_synced_at":"2025-05-16T06:05:37.967Z","repository":{"id":6704601,"uuid":"7950095","full_name":"lightswitch05/table-to-json","owner":"lightswitch05","description":"Serializes HTML tables into JSON objects.","archived":false,"fork":false,"pushed_at":"2020-01-22T13:57:40.000Z","size":198,"stargazers_count":755,"open_issues_count":2,"forks_count":174,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-05-08T17:57:12.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://lightswitch05.github.io/table-to-json/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightswitch05.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-01T02:14:02.000Z","updated_at":"2025-04-24T08:08:13.000Z","dependencies_parsed_at":"2022-07-31T04:08:53.373Z","dependency_job_id":null,"html_url":"https://github.com/lightswitch05/table-to-json","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightswitch05%2Ftable-to-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightswitch05%2Ftable-to-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightswitch05%2Ftable-to-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightswitch05%2Ftable-to-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightswitch05","download_url":"https://codeload.github.com/lightswitch05/table-to-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478188,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:01:23.912Z","updated_at":"2025-05-16T06:05:37.525Z","avatar_url":"https://github.com/lightswitch05.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Table To JSON\n\n[![Build Status](https://travis-ci.org/lightswitch05/table-to-json.png?branch=master)](https://travis-ci.org/lightswitch05/table-to-json)\n[![license](https://img.shields.io/github/license/lightswitch05/table-to-json.svg)](https://github.com/lightswitch05/table-to-json/blob/master/MIT-LICENSE)\n\njQuery plugin to serialize HTML tables into javascript objects.\n\n## Links\n- Demo: https://lightswitch05.github.io/table-to-json/\n- Plunker Template: https://plnkr.co/edit/iQFtcEEZkvsMJ2UqcrlW?p=preview\n\n## CDN\n\nIt is recommended to pull this tool into your project directly. But if you insist to use a CDN, here is one:\n\n```\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/table-to-json@1.0.0/lib/jquery.tabletojson.min.js\" integrity=\"sha256-H8xrCe0tZFi/C2CgxkmiGksqVaxhW0PFcUKZJZo1yNU=\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n```\n\n## Features\n- Automatically finds column headings\n  - Override found column headings by using `data-override=\"overridden column name\"`\n  - Always uses first row as column headings regardless of `th` and `td` tags\n- Override cell values column names by using `data-override=\"new value\"`\n- Ignorable columns\n- Not confused by nested tables\n- Works with `rowspan` and `colspan`\n\n## Options\n- `ignoreColumns`\n  - Array of column indexes to ignore.\n  - Default: `[]`\n- `onlyColumns`\n  - Array of column indexes to include, all other columns are ignored. This takes presidence over `ignoreColumns` when provided.\n  - Default: `null` - all columns\n- `ignoreHiddenRows`\n  - Boolean if hidden rows should be ignored or not.\n  - Default: `true`\n- `ignoreEmptyRows`\n  - Boolean if empty rows should be ignored or not.\n  - Default: `false`\n- `headings`\n  - Array of table headings to use. When supplied, treats entire table as values including the first `\u003ctr\u003e`\n  - Default: `null`\n- `allowHTML`\n  - Boolean if HTML tags in table cells should be preserved\n  - Default: `false`\n- `includeRowId`\n  - Either a `boolean` or a `string`. If `true`, the the `id` attribute on the table's `\u003ctr\u003e` elements will be included in the JSON as `rowId`. To override the name `rowId`, supply a string of the name you would like to use.\n  - Default: `false`\n- `textDataOverride`\n  - String containing data-attribute which contains data which overrides the text contained within the table cell\n  - Default: 'data-override'\n- `textExtractor`\n  - alias of `extractor`\n- `extractor`\n  - Function : function that is used on all *tbody* cells to extract text from the cells; a value in `data-override` will prevent this function from being called. Example:\n\n    ```js\n    $('table').tableToJSON({\n      extractor : function(cellIndex, $cell) {\n        // get text from the span inside table cells;\n        // if empty or non-existant, get the cell text\n        return $cell.find('span').text() || $cell.text();\n      }\n    });\n    ```\n\n    ```js\n    $('table').tableToJSON({\n      extractor : function(cellIndex, $cell) {\n        return {\n          name: $cell.find('span').text(),\n          avatar: $cell.find('img').attr('src')\n        };\n      }\n    });\n    ```\n\n  - Object : object containing a zero-based cell index (this *does not* take `colspan` cells into account!) of the table; a value in `data-override` will prevent this function from being called. Example:\n\n    ```js\n    $('table').tableToJSON({\n      extractor : {\n        0 : function(cellIndex, $cell) {\n          return $cell.find('em').text();\n        },\n        1 : function(cellIndex, $cell) {\n          return $cell.find('span').text();\n        }\n      }\n    });\n    ```\n\n  - Default: `null`\n\n## Example\n\n```html\n\u003ctable id='example-table'\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eFirst Name\u003c/th\u003e\n      \u003cth\u003eLast Name\u003c/th\u003e\n      \u003cth data-override=\"Score\"\u003ePoints\u003c/th\u003e\u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eJill\u003c/td\u003e\n      \u003ctd\u003eSmith\u003c/td\u003e\n      \u003ctd data-override=\"disqualified\"\u003e50\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eEve\u003c/td\u003e\n      \u003ctd\u003eJackson\u003c/td\u003e\n      \u003ctd\u003e94\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eJohn\u003c/td\u003e\n      \u003ctd\u003eDoe\u003c/td\u003e\n      \u003ctd\u003e80\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eAdam\u003c/td\u003e\n      \u003ctd\u003eJohnson\u003c/td\u003e\n      \u003ctd\u003e67\u003c/td\u003e\u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003cscript type=\"text/javascript\"\u003e\n  // Basic Usage\n  var table = $('#example-table').tableToJSON();\n  // table == [{\"First Name\"=\u003e\"Jill\", \"Last Name\"=\u003e\"Smith\", \"Score\"=\u003e\"disqualified\"},\n  //           {\"First Name\"=\u003e\"Eve\", \"Last Name\"=\u003e\"Jackson\", \"Score\"=\u003e\"94\"},\n  //           {\"First Name\"=\u003e\"John\", \"Last Name\"=\u003e\"Doe\", \"Score\"=\u003e\"80\"},\n  //           {\"First Name\"=\u003e\"Adam\", \"Last Name\"=\u003e\"Johnson\", \"Score\"=\u003e\"67\"}]\n\n  // Ignore first column (name)\n  var table = $('#example-table').tableToJSON({\n        ignoreColumns: [0]\n  });\n  // table == [{\"Last Name\"=\u003e\"Smith\", \"Score\"=\u003e\"disqualified\"},\n  //           {\"Last Name\"=\u003e\"Jackson\", \"Score\"=\u003e\"94\"},\n  //           {\"Last Name\"=\u003e\"Doe\", \"Score\"=\u003e\"80\"},\n  //           {\"Last Name\"=\u003e\"Johnson\", \"Score\"=\u003e\"67\"}]\n\u003c/script\u003e\n```\n\n## Contributing\n\n* Install [Node.js](https://nodejs.org).\n  * this will also the `npm` package manager.\n* run `npm install` from app root directory.\n  * This installs grunt and other dependencies See `package.json` for a full list.\n* run `npm install -g grunt-cli`.\n* run `grunt` to run tests and create a new build in `/lib`.\n* Make the changes you want.\n* Make tests for the changes.\n* Submit a pull request, please submit to the `develop` branch.\n\n### Looking for a server-side solution?\n\n[Colin Tremblay](https://github.com/tremblay) is working on a PHP implementation at [HTML-Table-To-JSON](https://github.com/tremblay/HTML-Table-to-JSON)\n\n### Special Thanks\n* [imamathwiz](https://github.com/imamathwiz) for adding `allowHTML` option and various other changes.\n* [nenads](https://github.com/nenads) for adding `headings` option.\n* [Mottie](https://github.com/Mottie) for adding `rowspan` \u0026 `colspan` support. Also adding the `textExtractor` \u0026 `dataOverride` feature!\n* [station384](https://github.com/station384) for adding `includeRowId` support.\n* [dayAlone](https://github.com/dayAlone) for adding `ignoreEmptyRows` option.\n* [danielapsmaior](https://github.com/danielapsmaior) for discovering and fixing a `rowspan` \u0026 `colspan` bug.\n* [koshuang](https://github.com/koshuang) for adding `extractor` feature!\n* [noma4i](https://github.com/noma4i) added feature \"Skip columns where headers are not present\"\n* [cn-tools](https://github.com/cn-tools) for reporting AND fixing a bug when using both `ignoreEmptyRows` and `ignoreColumns` options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightswitch05%2Ftable-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightswitch05%2Ftable-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightswitch05%2Ftable-to-json/lists"}