How to Create JSON File?

Jun 21, 2020

3 mins read

Published in
How to create JSON file. This article helps to create valid JSON document File.

To create a JSON file first we need to understand what is JSON and what it represents. Please check out this link to find more about the JSON What is JSON?

Once we understand JSON, there are 3 ways to create a new JSON.

  1. Using Text Editor
  2. Using Online Tools such as
  3. Create a file from the JSON URL

1. Using Text Editor

Open a Text editor like Notepad, Visual Studio Code, Sublime, or your favorite one.

Copy and Paste below JSON data in Text Editor or create your own base on the What is JSON article.

"InsuranceCompanies": {
 "Top Insurance Companies": [
   "No": "1",
   "Name": "Berkshire Hathaway",
   "Market Capitalization": "$308 B"
   "source": "",
   "Time": "Feb 2019"

Use this JSON validator tool to validate the JSON

Once file data are validated, save the file with the extension of .json, and now you know how to create the Valid JSON document.

2. Using Online Tool

Open a JSON Formatter tool from the link below

Copy and Paste the JSON Data which is mentioned in Option 1 in the Input tool of the online tool helps to create , validate and format the JSON Data

Click on the Download icon Highlighted in Red from the right textarea

Download this file using the download icon mentioned on the Right input area. It will download the JSON file.

This already supports the JSON validation. This will create a New JSON file and will allow downloading.

Now if you already have a JSON document or file, you can upload it to this tool and modify or delete a few objects, an array of the JSON and download the updated and valid JSON file.

This tool also help to create a JSON from text file. Upload text file using the upload file button and JSON will be automatically validated and beautified.

3. Create a file from the JSON URL

Developer needs to work with API and nowadays 95% of API returns data as JSON.

Here are few samples of the JSON URL. Now click on these JSON samples.

  1. https://gist.​​/jimmibond/​9205480889e19c0de347​/raw/sample.json

  2. https://gist.​​/cbmgit/​852c2702d4342e​7811c95f8ffc2f017f​/raw/InsuranceCompanies.json

Once these links are open, use save as functionality of the browser and save these links as files. It will generate JSON file and save it on your device.

I hope this article helps you to understand basic ways to make or create valid JSON files and beautify them.

3.1 Create json file in linux

Use jq command to create a JSON file in linux. This command will build json file in current directory.

jq -n --arg greeting GoodMorning 
'{"hello":$greeting}' > sample.json

jq is a lightweight and flexible command-line JSON processor. Install jq in ubuntu using sudo apt-get install jq

Know More about JSON :

Sharing is caring!