Codelab Editor
Free Online HTML Editor
Run
Learn JSON
<!DOCTYPE html> <html> <head> <style> body { padding: 10px; background: #fdfdfd; font-family: sans-serif; } .user-card { display: none; max-width: 320px; padding: 16px; border: 1px solid #ccc; border-radius: 12px; background-color: #f5f5f5; margin-top: 20px; } .user-card h3 { margin: 0 0 10px; font-size: 20px; } .user-card p { margin: 6px 0; } button { margin-right: 10px; padding: 8px 16px; border: none; background-color: #0088cc; color: white; border-radius: 6px; cursor: pointer; } button:hover { background-color: #006fa3; } </style> </head> <body> <h2>Parsing Large Integers in JSON</h2> <p>Click below to parse a JSON string that includes a large integer, and safely convert it to a <code>BigInt</code> using a reviver.</p> <button onclick="loadWidget()">Parse Widget Data</button> <div class="user-card" id="widgetCard"> <h3 id="widgetName"></h3> <p><strong>ID (BigInt):</strong> <span id="widgetId"></span></p> <p><strong>Type:</strong> <span id="widgetType"></span></p> </div> <script> function loadWidget() { const jsonText = '{"id":"9007199254740993","name":"MegaWidget","type":"Hardware"}'; const widget = JSON.parse(jsonText, (key, value) => { return key === "id" ? BigInt(value) : value; }); document.getElementById('widgetName').textContent = widget.name; document.getElementById('widgetId').textContent = widget.id + 'n'; document.getElementById('widgetType').textContent = widget.type; document.getElementById('widgetCard').style.display = 'block'; } </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console