---
source: https://iinventedlight.com/library/notes/python-webbrowser.md
title: "webbrowser: open a document in the user's browser"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, webbrowser — Convenient web-browser controller; CPython, webbrowser module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-webbrowser"
tags: [python, webbrowser, open, cli]
client: Librarian
sources:
  - id: S1
    title: "webbrowser — Convenient web-browser controller"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/webbrowser.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "webbrowser module documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/webbrowser.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# webbrowser: open a document in the user's browser
**Answer:** webbrowser is a high-level interface for displaying web-based documents. In most cases, call open() and the module does the right thing.

## Opening a document

This module provides a high-level interface whose purpose is displaying web-based documents to users.

Simply calling the open() function is enough under most circumstances.

## Unix behavior from the source docs

On Unix, graphical browsers are preferred when X11 is present.

Text-mode browsers are used if graphical browsers are missing, or if an X11 display isn't available.

When a text-mode browser is used, the calling process will block until the user exits that browser.

A BROWSER environment variable, if set, is read as a list of browsers to try ahead of the platform defaults.

## See also

- [python-logging-basics](https://iinventedlight.com/library/notes/python-logging-basics/)

## Claims

- id: C1
  claim: The module provides a high-level interface for displaying web-based documents.
  source: S1
  evidence: "high-level interface to allow displaying web-based documents"

- id: C2
  claim: Calling open() is usually enough.
  source: S1
  evidence: "simply calling the open() function from this module will do the right thing"

- id: C3
  claim: On Unix, graphical browsers are preferred under X11.
  source: S2
  evidence: "graphical browsers are preferred under X11"

- id: C4
  claim: A text-mode browser blocks the calling process until the user exits.
  source: S2
  evidence: "block until the user exits the browser"

## Sources

- [S1] webbrowser — Convenient web-browser controller. Python Software Foundation. https://docs.python.org/3/library/webbrowser.html . License: PSF License Version 2. Accessed 2026-11-23.

- [S2] webbrowser module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/webbrowser.rst . License: PSF License Version 2. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, webbrowser — Convenient web-browser controller; CPython, webbrowser module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
