Pretty Print JSON

I used to use a website to pretty-print my JSON. But realized that the site saves the data. If there’s data that could be confidential, it may not be a good idea use a 3rd party website. So I created a simple hosted page to pretty print a JSON.

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script type="text/javascript">
function onSubmit(){
	var $json_input = $( "#ta_json_input" );
	var json_out = JSON.stringify(JSON.parse($json_input.val()), null, 4);
	$json_input.val(json_out);
}
</script>
</head>
<body>
<form id="frmJson" name="frmJson">
<h2>Pretty JSON</h2>
<div>
<textarea id="ta_json_input" rows="30" style="width:100%; overflow-x: scroll; "></textarea>
</div>
<div>
<input type="button" value="Submit" onclick="onSubmit()" style="height:30px;">
</div>
</form>
</body>
</html>

Here’s how the page looks like:

Advertisements

One thought on “Pretty Print JSON

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s