Polymer Web Component for transforming any text data to JSON:

Basically a web component wrapper over Kash Nouroozi’s CSV.js library.

Live Examples


Column Options

Inlined Content

Comma-Separated Values (CSV)

Tab-Separated Values (TSV)

Space-Separated Columns


  1. Add the library using the Javascript package manager Bower:

    bower install --save transform-to-json

  2. Import Web Components’ polyfill:

     <script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
  3. Import Custom Element:

     <link rel="import" href="bower_components/transform-to-json/transform-to-json.html">
  4. Start using it!

         <!-- columns go here -->
         <!-- data can go here or you can use AJAX -->


Attribute Type Default Description
input string null Input to parse (can be populated via url or inlined)
url string null URL of input
json object null Parsed output
format string csv Format of input, allowed: csv, tsv, ssv, fixed
trim boolean false If true, output will be trimmed right to remove trailing spaces and newlines
array boolean false If true, output JSON array rather than JSON object (will drop property names)
firstrownames boolean false If true, first line of data is assumed to contain the names of the columns. Use Column Definitions to specify names if not included.

Any non-whitespace, non-commented text within the <transform-to-json> nodes will be treated as input.


jsonchanged will fire whenever json changes. Useful whenever url is defined as input will be loaded asynchronously via AJAX.

Column Definitions

Column fields can be named and parsed by defining <column> elements inside the <transform-to-json> HTML element.

Attribute Type Description
name string Name of column field. If columns are unspecified by either a firstrownames or column definitions, JSON output will be disabled.
type string Parse as type: String,String?,Number,Number?,Integer?, or Boolean are allowed.

There is more documentation on column.




For detailed changelog, check Releases.


MIT License © Steven Skelton