What a JSON file is and why you might create one
A JSON file is a text document that stores data in a format computers can read and organize. JSON stands for JavaScript Object Notation. It uses curly braces, square brackets, and quotation marks to structure information into pairs — a label and a value — so that programs can find and use the data reliably.
You might create a JSON file to store settings for a program you're building, to export data from one application and import it into another, to keep a list of items organized in a way a database can read, or to share structured information with someone else. Unlike a spreadsheet or a Word document, a JSON file is plain text, which means almost any program can open it and almost any programming language can read it.
The most common way to create a JSON file is to write the content in a text editor, save it with a .json extension, and then use it in whatever program needs it. You do not need special software — a basic text editor is enough.
Key Takeaways
- A JSON file is plain text saved with a .json extension, and you can create one in any text editor including Notepad on Windows or TextEdit on Mac.
- JSON data uses curly braces for objects, square brackets for lists, and quotation marks around text values, with each piece of data labeled with a name.
- The most common mistake is forgetting commas between items or putting a comma after the last item, which breaks the file.
- You can test whether your JSON file is correctly formatted by pasting it into an online JSON validator before you use it in a program.
Creating a JSON file in a text editor
Open a text editor on your computer. On Windows, use Notepad — press the Windows key, type "notepad", and open the application. On Mac, open Applications, then Utilities, then TextEdit. On Linux, use a text editor like gedit or nano.
Type or paste your JSON content into the editor. A simple example might look like this:
{ "name": "James Rodriguez", "age": 28, "city": "Portland", "skills": ["writing", "research", "editing"] }
Notice the structure: the whole thing is wrapped in curly braces. Inside, each piece of data has a label in quotation marks (like "name"), followed by a colon, followed by the value (like "James Rodriguez", also in quotation marks). Items are separated by commas. A list of items uses square brackets and commas between each item.
Once you have typed your content, save the file. Go to File, then Save As. Type a filename with the .json extension — for example, "contacts.json" or "settings.json". Choose a location on your computer where you can find it later. Click Save.
Understanding JSON structure and formatting rules
JSON has strict rules about how data must be arranged, or it will not work. Text values must always be in quotation marks. Numbers and true/false values do not need quotes. Every item except the last one in a list or object must have a comma after it — but the last item must not have a comma.
Here is a more complex example showing different data types:
{ "company": "Everyday Tech", "employees": 12, "active": true, "locations": ["Portland", "Seattle", "Denver"], "contact": { "email": "info@everydaytech.com", "phone": "555-0123" } }
In this example, "company" and "contact" are text (in quotes), "employees" is a number (no quotes), "active" is true or false (no quotes), "locations" is a list in square brackets, and "contact" is an object inside the main object, also in curly braces. Notice that there is a comma after "locations" because more items follow, but no comma after the closing brace of "contact" because it is the last item.
The most common errors are forgetting a comma between items, adding a comma after the last item, using single quotes instead of double quotes, or forgetting to close a curly brace or square bracket. If your JSON file has any of these mistakes, programs that try to read it will reject it.
Checking your JSON file for errors
Before you use your JSON file in a program, you should check whether it is formatted correctly. Copy all the text from your file. Go to a website like jsonlint.com or jsonformatter.org in your web browser. Paste your JSON into the text box and click the button to validate or check the format.
If the validator finds an error, it will tell you which line the problem is on and what is wrong — for example, "missing comma on line 5" or "unexpected character on line 3". Go back to your text editor, find that line, and fix the mistake. Then copy the corrected text, paste it into the validator again, and check once more.
Once the validator says your JSON is correct, your file is ready to use. You can also open your JSON file in a web browser to see if it displays or shows an error message, though a validator is more reliable.
Using your JSON file in programs and applications
Once your JSON file is created and saved, you can use it in different ways depending on what program needs it. Some applications let you import a JSON file directly — you go to File or Settings, look for an Import option, and select your JSON file from your computer. Other programs expect you to paste the JSON content into a text field or configuration window.
If you are building a website or application yourself, you would typically place the JSON file in the same folder as your code and reference it by filename. If you are sharing the JSON file with someone else, you can email it, upload it to a shared folder, or post it on a website.
You can edit a JSON file at any time by opening it in your text editor, making changes, saving it, and then validating it again. If you make a mistake and want to start over, you can delete the file and create a new one.
Common mistakes and how to avoid them
The most frequent error is forgetting commas between items. Remember: every item in a list or object needs a comma after it, except the last one. If you have three items, you need two commas.
Another common mistake is using the wrong type of quotation mark. JSON requires straight double quotes (" "), not curly or smart quotes (" "). If you copy JSON from a website or a word processor like Microsoft Word, the quotes might be curly, and you will need to replace them with straight quotes. A text editor like Notepad produces straight quotes automatically.
A third mistake is nesting objects or lists incorrectly. If you open a curly brace or square bracket, you must close it before the parent object closes. Use indentation (spaces or tabs at the beginning of lines) to keep track of what is inside what, even though JSON does not require it. Indentation makes errors much easier to spot.
Frequently Asked Questions
Can I create a JSON file in Microsoft Word or Google Docs?
You can type JSON content in Word or Google Docs, but you must save it as plain text, not as a Word document or Google Doc. Save it as a .txt file first, then rename the file extension to .json. It is simpler to use a plain text editor from the start.
What if I have a lot of data and do not want to type it all manually?
If you have data in a spreadsheet, you can use online conversion tools to turn it into JSON format. Search for "CSV to JSON converter" or "Excel to JSON converter", upload your file, and the tool will generate the JSON for you. You can then copy the output into a text editor and save it as a .json file.
Do I need to know programming to create a JSON file?
No. You only need to understand the basic structure — curly braces for objects, square brackets for lists, quotation marks around text, and commas between items. You do not need to write code or understand how a program will use the file.
Can I open a JSON file in Excel or another spreadsheet program?
Some spreadsheet programs can import JSON, but the result depends on how the data is structured. A simple list of objects might import as rows and columns, but nested data or complex structures may not display correctly. A text editor is the most reliable way to view and edit JSON.
What is the difference between a JSON file and a text file?
A JSON file is a text file with a .json extension. The extension tells programs that the content follows JSON formatting rules. You can open both in a text editor, but a program expecting JSON will only read a file with the .json extension.