How to Open JSON File? (original) (raw)

Last Updated : 23 Jul, 2025

JSON (JavaScript Object Notation) is a lightweight, text-based data format that stores and exchanges data. Let's see how we can create and open a JSON file.

**How to Create JSON Files?

Before learning how to open a JSON file, it's important to know how to create one. Below are the basic steps to create a JSON file:

**Sample JSON File

JavaScript `

{ "name": "Amit Kumar", "age": 30, "city": "New Delhi" }

`

**Open JSON Files

1. Opening JSON in a Text Editor

If you want to quickly view or edit a JSON file, a text editor like Notepad, Visual Studio Code, or Sublime Text works best.

**Advantages

2. Opening JSON in a Web Browser

Browsers like Chrome and Firefox automatically format JSON data in a readable way, making them a great option for viewing JSON files.

**Advantages:

3. Opening JSON with Python

Python has built-in support for reading JSON files. You can use the json module to load the content into Python objects.

Python `

import json

Open the JSON file

with open('path/to/your/file.json', 'r') as file: data = json.load(file)

Print the data

print(data)

`

The json.load() method reads the content and converts it into Python objects (like dictionaries and lists).

**Advantages:

4. Opening JSON with JavaScript

JavaScript is another great tool for working with JSON files, especially for web developers.

JavaScript `

fetch('path/to/your/file.json') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.log('Error:', error));

`