What a JSON file is and why you might create one

A JSON file is a plain-text document that stores data in a format computers can read and organize. JSON stands for JavaScript Object Notation. Unlike a spreadsheet or database, a JSON file uses a specific structure: curly braces for objects, square brackets for lists, and pairs of names and values separated by colons. You might create one to store contact information, configuration settings for a program, or data you plan to share with someone else or import into another process.

The file itself is just text — you can open and edit it in any text editor on your computer. What makes it JSON is the way the data is formatted inside. A computer program reading the file knows exactly where to find each piece of information because of that structure.

Key Takeaways

  • A JSON file is plain text formatted with specific rules: curly braces for objects, square brackets for lists, and colons between names and values.
  • You create a JSON file by typing or pasting the data into any text editor, then saving it with the .json file extension instead of .txt.
  • Common mistakes include forgetting commas between items, using single quotes instead of double quotes, or leaving a trailing comma after the last item.
  • You can validate your JSON file using free online tools to catch formatting errors before you use it.
  • Once saved, a JSON file can be opened in any text editor, imported into applications, or shared with others who need the data.

The basic structure and rules of JSON formatting

JSON has four core rules. First, all text values must be wrapped in double quotes — not single quotes. Second, names (called keys) must also be in double quotes, followed by a colon, then the value. Third, items in a list are separated by commas, but there should never be a comma after the last item. Fourth, curly braces {} hold objects (collections of name-value pairs), and square brackets [] hold arrays (lists of values).

Here is a straightforward example. If you wanted to store information about a person, it would look like this:

{ "name": "Sarah Chen", "age": 34, "city": "Portland", "email": "sarah@example.com" }

Notice the double quotes around the names and text values, the colons after each name, and the commas between pairs — but not after the last one. Numbers like age do not need quotes. If you wanted to store multiple people, you would use square brackets and list them:

[ { "name": "Sarah Chen", "age": 34 }, { "name": "Marcus Webb", "age": 41 } ]

Creating a JSON file on Windows

Open Notepad, which comes built into Windows. Click the Start button, type Notepad, and press Enter. A blank text window opens. Type or paste your JSON data into it, making sure to follow the formatting rules — double quotes around text, colons after names, commas between items.

Once your data is in the file, go to File > Save As. A dialog box appears. In the field labeled File name, type a name for your file followed by .json — for example, contacts.json or settings.json. In the Save as type dropdown, select All Files (*.*) instead of Text Documents. This tells Windows to save it as a JSON file, not a .txt file. Choose where you want to save it, then click Save.

If you do not change the file type dropdown, Windows will save it as contacts.json.txt, which will cause problems when you try to use it. The dropdown is the critical step.

Creating a JSON file on Mac

Open TextEdit, which is in your Applications folder under Utilities. When it opens, go to Format menu and select Make Plain Text. This is important — TextEdit normally saves files with formatting, which will break your JSON file. Once you switch to plain text mode, type or paste your JSON data.

Go to File > Save. In the dialog that appears, give your file a name with the .json extension — for example, contacts.json. Make sure the checkbox labeled If no extension is provided, use .txt is unchecked. If it is checked, uncheck it. Then click Save.

If you prefer a different editor, you can also use Sublime Text, Visual Studio Code, or any other plain-text editor available on Mac. The steps are the same: write your JSON, save it with the .json extension, and make sure you are saving as plain text, not rich text.

Creating a JSON file on Linux

Open a terminal and use a text editor like nano or vi. Type nano myfile.json (replace myfile with whatever you want to call it). The nano editor opens with a blank file. Type or paste your JSON data. When you are done, press Ctrl + X, then Y to confirm you want to save, then Enter to accept the filename. The file is saved.

If you prefer a graphical editor, open your file manager, right-click in the folder where you want the file, and select Create Document or New File. Name it with the .json extension, then right-click it and open it with a text editor like gedit or Kate. Type your JSON data and save it.

Checking your JSON file for errors

The most common mistakes are forgetting a comma between items, using single quotes instead of double quotes, or leaving a comma after the last item in a list. If your JSON file has errors, programs that try to read it will fail silently or show an error message.

To catch these mistakes before you use the file, paste your JSON into a free online validator. Search for "JSON validator" in your browser. Websites like jsonlint.com or jsonformatter.org let you paste your entire file and check it when ready. If there is an error, the tool will tell you exactly which line it is on and what is wrong. Fix the error in your text editor, save the file, and validate it again.

This step takes 30 seconds and saves you hours of troubleshooting later.

Opening and using your JSON file

Once your JSON file is saved, you can open it in any text editor to view or edit it. Double-click the file, and it will open in your default text editor. Make your changes, save the file, and it is updated.

To use the data in your JSON file with another program, that program needs to support JSON import. Many applications do — spreadsheet programs, database tools, web applications, and data analysis software all accept JSON files. Check the program's documentation to see where the import option is. Usually it is under File > Import or Open. Select your JSON file, and the program reads the data and organizes it according to its own format.

You can also share your JSON file with others by email or cloud storage. Since it is plain text, anyone with a text editor can open it and see the data inside.

Frequently Asked Questions

What is the difference between JSON and CSV?

CSV (comma-separated values) is simpler — it is just rows and columns, like a spreadsheet. JSON is more structured and can handle nested data, lists within lists, and more complex relationships. Use CSV if your data is straightforward and flat. Use JSON if you need to store related information together or share data with a web process.

Can I edit a JSON file after I create it?

Yes. Open it in any text editor, make your changes, and save it. Be careful to keep the formatting correct — if you add a new item, remember to add a comma after the previous item. Validate the file again after you make changes to catch any mistakes.

What if I accidentally saved my JSON file as a .txt file?

Right-click the file, select Rename, and change the extension from .txt to .json. The file itself does not change — only the label Windows or Mac uses to identify it. As long as the content inside is properly formatted JSON, it will work.

Do I need special software to create a JSON file?

No. Any text editor that comes with your computer works — Notepad on Windows, TextEdit on Mac, or nano on Linux. You do not need to buy anything. If you create JSON files regularly, you might prefer a code editor like Visual Studio Code, which highlights errors and makes formatting easier, but it is not required.

Can I use JSON to back up my files?

JSON is good for storing structured data like contact lists, settings, or configuration information. It is not designed for backing up entire files or folders. For that, use your operating system's backup tools or cloud storage. JSON works best when you want to organize specific information in a format that is straightforward to share and read.