Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

beautify json in html

// Assuming in your HTML code you have the following element
// <pre id="json"></pre>
// Include the code below in your JS file

const data = {
    "data": {
        "x": "1",
        "y": "1",
        "url": "http://url.com"
    },
    "event": "start",
    "show": 1,
    "id": 50
}


document.getElementById("json").innerHTML = JSON.stringify(data, undefined, 2);
Source by jsfiddle.net #
 
PREVIOUS NEXT
Tagged: #beautify #json #html
ADD COMMENT
Topic
Name
2+9 =