Socket
Socket
Sign inDemoInstall

htmlescape

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    htmlescape

Properly escape JSON for usage as an object literal inside of a `<script>` tag


Version published
Weekly downloads
968K
decreased by-0.24%
Maintainers
1
Install size
4.13 kB
Created
Weekly downloads
 

Readme

Source

htmlescape

Properly escape JSON for usage as an object literal inside of a <script> tag. Use htmlescape in place of JSON.stringify. For more info see JSON: The JavaScript subset that isn't.

Transformations

fromto
&\\u0026
>\\u003e
<\\u003c
\u2028\\u2028
\u2029\\u2029

Usage

var htmlescape = require('htmlescape');
htmlescape({prop:'value'});
//=> '{"prop":"value"}'

Or in your templates:

<script>
var payload = <%= htmlescape(payload) %>;
</script>

Keywords

FAQs

Last updated on 23 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc