✨ Format json and highlight it as well.
You can play with @crashmax/json-format-highlight
on foorks.github.io/json-format-highlight or codesandbox.io
- 🔥 Zero dependencies
- 📦 Lightweight (806B gzipped)
- ⚙️ Styling is self-contained, no need to setup CSS
Note:
- May not be suitable for handling huge (such as 10MB) JSON.
# with npm:
npm install @crashmax/json-format-highlight
# or yarn:
yarn add @crashmax/json-format-highlight
import formatHighlight from '@crashmax/json-format-highlight'
const json = {
ok: true,
status: 200,
message: 'hello world'
}
formatHighlight(json, /** options */)
Key | Type | Default | Description |
---|---|---|---|
keyColor | string | #9cdcfe |
Key color |
numberColor | string | #569cd6 |
Color of the value of the number type |
stringColor | string | #ce9178 |
Color of the value of the string type |
trueColor | string | #569cd6 |
Color of the value of the boolean type and equals to true |
falseColor | string | #569cd6 |
Color of the value of the string type and equals to false |
nullColor | string | #569cd6 |
Color of the value of the null type |
bracketsColor | string | #d4d4d4 |
Color of the brackets symbol |
backgroundColor | string | #1e1e1e |
Color of the background |
If you don't pass in anything this argument, default colors would be used. If you do pass in an object for this argument, the colors you specified would override the default color scheme.
MIT © luyilin
minemine.cc · GitHub @luyilin · Twitter @luyilin12