• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
Add-ons
  1. MDN
  2. Mozilla
  3. Add-ons
  4. Creating OpenSearch plugins for Firefox

Creating OpenSearch plugins for Firefox

In This Article
  1. OpenSearch description file
  2. Autodiscovery of search plugins
  3. Supporting automatic updates for OpenSearch plugins
  4. Troubleshooting Tips
  5. Reference Material

Firefox supports the OpenSearch description format for search plugins. OpenSearch plugins are also compatible with Internet Explorer, Safari, and Chrome.

Firefox also supports additional features not included in the OpenSearch standard, such as search suggestions and the <SearchForm> element. This article focuses on creating OpenSearch-compatible search plugins that support these additional Firefox features.

OpenSearch description files can be advertised as described in Autodiscovery of search plugins, and can be installed programmatically as described in Adding search engines from web pages.

OpenSearch description file

The XML file describing a search engine follows the basic template below. Sections in bold should be customized for the specific plugin you're writing.

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>SNK</ShortName>
  <Description>Search engine full name and summary</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">data:image/x-icon;base64,AAABAAEAEBAAA ...</Image>
  <Url type="text/html" template="searchURL">
    <Param name="key name" value="{searchTerms}"/>
    ...
    <Param name="key name" value="parameter value"/>
  </Url>
  <Url type="application/x-suggestions+json" template="suggestionURL"/>
  <moz:SearchForm>http://example.com/search</moz:SearchForm>
</OpenSearchDescription>
ShortName
A short name for the search engine.
Restrictions: The value must contain 16 or fewer characters of plain text. The value must not contain HTML or other markup.
Description
A brief description of the search engine.
Restrictions: The value must contain 1024 or fewer characters of plain text. The value must not contain HTML or other markup.
InputEncoding
The character encoding to use for the data input to the search engine. Example: <InputEncoding>UTF-8</InputEncoding>.
Image

URI to an icon representative of the search engine. When possible, search engines should offer a 16×16 image of type "image/x-icon" and a 64×64 image of type image/jpeg or image/png. The URI may also use the data: URI scheme. You can generate a data: URI from an icon file at The data: URI kitchen.

<Image height="16" width="16" type="image/x-icon">https://example.com/favicon.ico</Image>
  <!-- or -->
<Image height="16" width="16">data:image/x-icon;base64,AAABAAEAEBAAA ... DAAA=</Image>

Firefox caches the icon as a base64 data: URI (search plug-ins are stored in the profile's "searchplugins" folder). http: URIs are changed to data: URIs when this is done.

Note: For icons loaded remotely (i.e. from https:// URIs as opposed to data: URIs), Firefox will reject icons larger than 10 kilobytes in size.

Search suggestions from Google displayed in Firefox's search box

Url
Describes the URL or URLs to use for the search. The method attribute indicates whether to use a GET or POST request to fetch the result. The template attribute indicates the base URL for the search query.
Firefox supports three URL types:
  • type="text/html" specifies the URL for the actual search query.
  • type="application/x-suggestions+json" specifies the URL for fetching search suggestions.
  • type="application/x-moz-keywordsearch" specifies the URL used when a keyword search is entered in the location bar. This is supported only in Firefox.

For these URL types, you can use {searchTerms} to substitute the search terms entered by the user in the search bar or location bar. Other supported dynamic search parameters are described in OpenSearch 1.1 parameters.

For search suggestion queries, the specified URL template is used to fetch a suggestion list in JavaScript Object Notation (JSON) format. For details on how to implement search suggestion support on a server, see Supporting search suggestions in search plugins.

Param
The parameters that need to be passed in along with the search query, as key/value pairs. When specifying values, you can use {searchTerms} to insert the search terms entered by the user in the search bar.
SearchForm
The URL to go to to open up the search page at the site for which the plugin is designed to search. This provides a way for Firefox to let the user visit the web site directly.
Note: Since this element is Firefox-specific, and not part of the OpenSearch specification, we use the "moz:" XML namespace prefix in the example above to ensure that other user agents that don't support this element can safely ignore it.

Autodiscovery of search plugins

Web sites offering search plugins can advertise them so Firefox users can easily download and install the plugins.

To support autodiscovery, add a <link> element for each plugin to the <head> section of your web page:

<link rel="search"
      type="application/opensearchdescription+xml"
      title="searchTitle"
      href="pluginURL">

Replace the bolded items as explained below:

searchTitle
The name of the search to perform, such as "Search MDC" or "Yahoo! Search". This value should match your plugin file's ShortName.
pluginURL
The URL to the XML search plugin, from which the browser can download it.

If your site offers multiple search plugins, you can support autodiscovery for them all. For example:

<link rel="search" type="application/opensearchdescription+xml"
      title="MySite: By Author" href="http://example.com/mysiteauthor.xml">
<link rel="search" type="application/opensearchdescription+xml"
      title="MySite: By Title" href="http://example.com/mysitetitle.xml">

This way, your site can offer plugins to search by author or by title as separate entities.

Supporting automatic updates for OpenSearch plugins

OpenSearch plugins can be updated automatically. To support this, include an extra Url element of type "application/opensearchdescription+xml". The rel attribute needs to be "self" and the template attribute needs to be the URL of the OpenSearch document to automatically update to.

For example:

<Url type="application/opensearchdescription+xml"
     rel="self"
     template="http://example.com/mysearchdescription.xml" />
Note: At this time, addons.mozilla.org (AMO) doesn't support automatic updating of OpenSearch plugins. If you want to put your search plugin on AMO, you shouldn't use the auto-updating feature.

Troubleshooting Tips

If there is a mistake in your Search Plugin XML, you could run into errors when adding a discovered plugin. If the error message isn't be helpful, the following tips could help you find the problem.

  • Your server should serve OpenSearch plugins using Content-Type: application/opensearchdescription+xml.
  • Be sure that your Search Plugin XML is well formed. You can check by loading the file directly into Firefox. Ampersands (&) in the template URL need to be escaped with &amp; and tags need to be closed with a trailing slash or matching end tag.
  • The xmlns attribute is important, without it you could get an error message indicating that "Firefox could not download the search plugin".
  • You must include a text/html URL — search plugins including only Atom or RSS URL types (which is valid, but Firefox doesn't support) will also generate the "could not download the search plugin" error.
  • Remotely fetched favicons must not be larger than 10KB (see bug 361923).

In addition, the search plugin service provides a logging mechanism that may be of use to plugin developers. Use about:config to set the pref 'browser.search.log' to true. Logging information will appear in Firefox's Error Console (Tools 〉 Error Console) when search plugins are added.

Reference Material

  • OpenSearch Documentation, OpenSearch Documentation about the Url and Param element
  • imdb.com has a working osd.xml
  • data: URI scheme
  • OpenSearch Plugin Generator
  • Ready2Search - create OpenSearch plugins. Customized Search through Ready2Search

Document Tags and Contributors

Tags: 
  • Add-ons
  • Guide
  • OpenSearch
  • Search
  • Search plugins
 Contributors to this page: Tigt, wbamberg, gottcha, jswisher, Sheppy, kscarfone, Havvy, kmaglione, mynameisnotjony, fellyph, Jan-, alberts+, Zibi, GavinSharp, MKaply, mavit, Wladimir_Palant, maitrey684, inma_610, fscholz, Zart, Nickolay, Buc11t, Psz, Gokulji, Tucker277, RyanFlint, Xeror, Grabennett, Citora, LLay, Sonika, Kaeto23, Fenomeno, Andreas Wuest, Ogrisel, Shimono, Fittizio, Marcellotalon, Tusc30, Toniher, Epierce, Merate, Taken, Tartoo, Apaxuc, Mickgam, Fabinou, Yuva9882, Proub, Planche, Mgjbot
 Last updated by: Tigt, Jan 23, 2017, 3:18:02 AM
See also
  1. WebExtensions
  2. Getting started
    1. What are WebExtensions?
    2. Your first WebExtension
    3. Your second WebExtension
    4. Anatomy of a WebExtension
    5. Example WebExtensions
  3. How to
    1. Intercept HTTP requests
    2. Modify a web page
    3. Add a button to the toolbar
    4. Implement a settings page
  4. Concepts
    1. Using the JavaScript APIs
    2. User interface components
    3. Content scripts
    4. Match patterns
    5. Internationalization
    6. Content Security Policy
    7. Native messaging
  5. Porting
    1. Porting a Google Chrome extension
    2. Porting a legacy Firefox add-on
    3. Embedded WebExtensions
    4. Comparison with the Add-on SDK
    5. Comparison with XUL/XPCOM extensions
    6. Chrome incompatibilities
  6. Firefox workflow
    1. Temporary Installation in Firefox
    2. Debugging
    3. Getting started with web-ext
    4. web-ext command reference
    5. WebExtensions and the Add-on ID
    6. Publishing your WebExtension
  7. JavaScript APIs
    1. Browser support for JavaScript APIs
    2. alarms
    3. bookmarks
    4. browserAction
    5. commands
    6. contextMenus
    7. cookies
    8. downloads
    9. events
    10. extension
    11. extensionTypes
    12. history
    13. i18n
    14. idle
    15. management
    16. notifications
    17. pageAction
    18. runtime
    19. sessions
    20. storage
    21. tabs
    22. topSites
    23. webNavigation
    24. webRequest
    25. windows
  8. Manifest keys
    1. applications
    2. author
    3. background
    4. browser_action
    5. commands
    6. content_scripts
    7. content_security_policy
    8. default_locale
    9. description
    10. developer
    11. homepage_url
    12. icons
    13. manifest_version
    14. name
    15. options_ui
    16. page_action
    17. permissions
    18. short_name
    19. version
    20. web_accessible_resources
  9. Add-on SDK
  10. Getting started
    1. Installation
    2. Getting started
    3. Troubleshooting
  11. High-Level APIs
    1. addon-page
    2. base64
    3. clipboard
    4. context-menu
    5. hotkeys
    6. indexed-db
    7. l10n
    8. notifications
    9. page-mod
    10. page-worker
    11. panel
    12. passwords
    13. private-browsing
    14. querystring
    15. request
    16. selection
    17. self
    18. simple-prefs
    19. simple-storage
    20. system
    21. tabs
    22. timers
    23. ui
    24. url
    25. webextension
    26. widget
    27. windows
  12. Low-Level APIs
    1. /loader
    2. chrome
    3. console/plain-text
    4. console/traceback
    5. content/content
    6. content/loader
    7. content/mod
    8. content/symbiont
    9. content/worker
    10. core/heritage
    11. core/namespace
    12. core/promise
    13. dev/panel
    14. event/core
    15. event/target
    16. frame/hidden-frame
    17. frame/utils
    18. fs/path
    19. io/byte-streams
    20. io/file
    21. io/text-streams
    22. lang/functional
    23. lang/type
    24. loader/cuddlefish
    25. loader/sandbox
    26. net/url
    27. net/xhr
    28. places/bookmarks
    29. places/favicon
    30. places/history
    31. platform/xpcom
    32. preferences/event-target
    33. preferences/service
    34. remote/child
    35. remote/parent
    36. stylesheet/style
    37. stylesheet/utils
    38. system/child_process
    39. system/environment
    40. system/events
    41. system/runtime
    42. system/unload
    43. system/xul-app
    44. tabs/utils
    45. test/assert
    46. test/harness
    47. test/httpd
    48. test/runner
    49. test/utils
    50. ui/button/action
    51. ui/button/toggle
    52. ui/frame
    53. ui/id
    54. ui/sidebar
    55. ui/toolbar
    56. util/array
    57. util/collection
    58. util/deprecate
    59. util/list
    60. util/match-pattern
    61. util/object
    62. util/uuid
    63. window/utils
  13. Firefox for Android
  14. Getting started
    1. Walkthrough
    2. Debugging
    3. Code snippets
  15. APIs
    1. Accounts.jsm
    2. BrowserApp
    3. HelperApps.jsm
    4. Home.jsm
    5. HomeProvider.jsm
    6. JavaAddonManager.jsm
    7. NativeWindow
    8. Notifications.jsm
    9. PageActions.jsm
    10. Prompt.jsm
    11. RuntimePermissions.jsm
    12. Snackbars.jsm
    13. Sound.jsm
    14. Tab
  16. Legacy
  17. Restartless extensions
    1. Overview
  18. Overlay extensions
    1. Overview
  19. Themes
  20. Lightweight themes
    1. Overview
  21. Complete themes
    1. Overview
  22. Publishing add-ons
  23. Guides
    1. Signing and distribution overview
    2. Submit an add-on
    3. Review policies
    4. Developer agreement
    5. Featured add-ons
    6. Contact addons.mozilla.org
  24. Community and support
  25. Channels
    1. Add-ons blog
    2. Add-on forums
    3. Stack Overflow
    4. Development newsgroup
    5. IRC Channel