google-chrome-extension

manifest.json

Remarks#

Official documentation

Manifest File Format

Format

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.

    • Correct:

      {
        "foo": "bar",
        "baz": "qux"
      }
    • Wrong (comma missing):

      {
        "foo": "bar"
        "baz": "qux"
      }
    • Wrong (dangling comma):

      {
        "foo": "bar",
        "baz": "qux",
      }

Absolute minimum manifest.json

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

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;

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow