Google Chrome Extension manifest.json

From WikiOD

Remarks[edit | edit source]

Official documentation[edit | edit source]

Manifest File Format

Format[edit | edit source]

Manifest file is written in JSON (JavaScript Object Notation) format.

This format differs from more loose rules of writing object literals in JavaScript code. Among important differences:

Every key name and string literal must be in double quotes.

Correct: "key": "value"

Wrong: key: "value", 'key': 'value'

No comments are allowed by the format.

  • Wrong: "key": "value" // This controls feature foo

Strict comma rules: items separated by commas, no dangling commas.


  "foo": "bar",
  "baz": "qux"

Wrong (comma missing):

  "foo": "bar"
  "baz": "qux"

Wrong (dangling comma):

  "foo": "bar",
  "baz": "qux",

Absolute minimum manifest.json[edit | edit source]

manifest.json gives information about the extension, such as the most important files and the capabilities that the extension might use. Among the supported manifest fields for extensions, the following three are required.

    "manifest_version": 2,
    "name": "My Extension",
    "version": "1.0"

Obtaining manifest from extension code[edit | edit source]

chrome.runtime.getManifest() returns the extension's manifest in a form of a parsed object.

This method works both on content scripts and all extension pages, it requires no permissions,

Example, obtaining the extension's version string:

var version = chrome.runtime.getManifest().version;