Gathering detailed insights and metrics for style-to-js
Gathering detailed insights and metrics for style-to-js
Gathering detailed insights and metrics for style-to-js
Gathering detailed insights and metrics for style-to-js
css-has-pseudo
Style elements relative to other elements in CSS
webpack-fix-style-only-entries
Package to fix style (css/sass/less) only entries generating a extra js file.
qr-code-styling
Add a style and an image to your QR code
prettyoutput
Librarie to format js/json objects into a YAML-style colored output. Especially useful to pretty print logs. Performant (benchmarks)
📝 Parses CSS inline style to JavaScript object (camelCased).
npm install style-to-js
Typescript
Module System
Node Version
NPM Version
TypeScript (80.3%)
JavaScript (19.7%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
13 Stars
884 Commits
3 Forks
1 Watchers
1 Branches
3 Contributors
Updated on Jul 08, 2025
Latest Version
1.1.17
Package Id
style-to-js@1.1.17
Unpacked Size
65.17 kB
Size
16.00 kB
File Count
19
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jun 16, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
23
Parses CSS inline style to JavaScript object (camelCased):
StyleToJS(string)
1import parse from 'style-to-js'; 2 3parse('background-color: #BADA55;');
Output:
1{ "backgroundColor": "#BADA55" }
NPM:
1npm install style-to-js --save
Yarn:
1yarn add style-to-js
CDN:
1<script src="https://unpkg.com/style-to-js@latest/umd/style-to-js.min.js"></script> 2<script> 3 window.StyleToJS(/* string */); 4</script>
Import with ES Modules:
1import parse from 'style-to-js';
Require with CommonJS:
1const parse = require('style-to-js');
Parse single declaration:
1parse('line-height: 42');
Output:
1{ "lineHeight": "42" }
Notice that the CSS property is camelCased.
Parse multiple declarations:
1parse(` 2 border-color: #ACE; 3 z-index: 1337; 4`);
Output:
1{ 2 "borderColor": "#ACE", 3 "zIndex": "1337" 4}
Parse vendor prefix:
1parse(` 2 -webkit-transition: all 4s ease; 3 -moz-transition: all 4s ease; 4 -ms-transition: all 4s ease; 5 -o-transition: all 4s ease; 6 -khtml-transition: all 4s ease; 7`);
Output:
1{ 2 "webkitTransition": "all 4s ease", 3 "mozTransition": "all 4s ease", 4 "msTransition": "all 4s ease", 5 "oTransition": "all 4s ease", 6 "khtmlTransition": "all 4s ease" 7}
Parse custom property:
1parse('--custom-property: #f00');
Output:
1{ "--custom-property": "#f00" }
This library does not validate declarations, so unknown declarations can be parsed:
1parse('the-answer: 42;');
Output:
1{ "theAnswer": "42" }
Declarations with missing value are removed:
1parse(` 2 margin-top: ; 3 margin-right: 1em; 4`);
Output:
1{ "marginRight": "1em" }
Other invalid declarations or arguments:
1parse(); // {} 2parse(null); // {} 3parse(1); // {} 4parse(true); // {} 5parse('top:'); // {} 6parse(':12px'); // {} 7parse(':'); // {} 8parse(';'); // {}
The following values will throw an error:
1parse('top'); // Uncaught Error: property missing ':' 2parse('/*'); // Uncaught Error: End of comment missing
When option reactCompat
is true, the vendor prefix will be capitalized:
1parse( 2 ` 3 -webkit-transition: all 4s ease; 4 -moz-transition: all 4s ease; 5 -ms-transition: all 4s ease; 6 -o-transition: all 4s ease; 7 -khtml-transition: all 4s ease; 8 `, 9 { reactCompat: true }, 10);
Output:
1{ 2 "WebkitTransition": "all 4s ease", 3 "MozTransition": "all 4s ease", 4 "msTransition": "all 4s ease", 5 "OTransition": "all 4s ease", 6 "KhtmlTransition": "all 4s ease" 7}
This removes the React warning:
Warning: Unsupported vendor-prefixed style property %s. Did you mean %s?%s", "oTransition", "OTransition"
Run tests with coverage:
1npm test
Run tests in watch mode:
1npm run test:watch
Lint files:
1npm run lint
Fix lint errors:
1npm run lint:fix
Release and publish are automated by Release Please.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
SAST tool is run on all commits
Details
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More