Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
OptionsPattern
  • See Also
    • OptionValue
    • BlankSequence
    • Repeated
    • FilterRules
    • CheckArguments
    • ArgumentsOptions
    • KeyValuePattern
  • Related Guides
    • Options Management
    • Package Development
    • Patterns
    • Robustness & Error Handling
  • Workflows
    • Define a Function with Options
  • Tech Notes
    • Patterns and Transformation Rules
    • Setting Up Functions with Optional Arguments
    • Manipulating Options
    • See Also
      • OptionValue
      • BlankSequence
      • Repeated
      • FilterRules
      • CheckArguments
      • ArgumentsOptions
      • KeyValuePattern
    • Related Guides
      • Options Management
      • Package Development
      • Patterns
      • Robustness & Error Handling
    • Workflows
      • Define a Function with Options
    • Tech Notes
      • Patterns and Transformation Rules
      • Setting Up Functions with Optional Arguments
      • Manipulating Options

OptionsPattern[]

is a pattern object that represents a collection of options given as rules, where the values of the options can be accessed using OptionValue.

OptionsPattern[f]

takes default option values from Options[f].

OptionsPattern[{opt1val1,opt2val2,…}]

uses an explicit list of default option values.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
Possible Issues  
See Also
Tech Notes
Related Guides
Related Workflows
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • OptionValue
    • BlankSequence
    • Repeated
    • FilterRules
    • CheckArguments
    • ArgumentsOptions
    • KeyValuePattern
  • Related Guides
    • Options Management
    • Package Development
    • Patterns
    • Robustness & Error Handling
  • Workflows
    • Define a Function with Options
  • Tech Notes
    • Patterns and Transformation Rules
    • Setting Up Functions with Optional Arguments
    • Manipulating Options
    • See Also
      • OptionValue
      • BlankSequence
      • Repeated
      • FilterRules
      • CheckArguments
      • ArgumentsOptions
      • KeyValuePattern
    • Related Guides
      • Options Management
      • Package Development
      • Patterns
      • Robustness & Error Handling
    • Workflows
      • Define a Function with Options
    • Tech Notes
      • Patterns and Transformation Rules
      • Setting Up Functions with Optional Arguments
      • Manipulating Options

OptionsPattern

OptionsPattern[]

is a pattern object that represents a collection of options given as rules, where the values of the options can be accessed using OptionValue.

OptionsPattern[f]

takes default option values from Options[f].

OptionsPattern[{opt1val1,opt2val2,…}]

uses an explicit list of default option values.

Details

  • OptionsPattern matches any sequence or nested list of rules, specified with -> or :>, whose left-hand sides are symbols or strings.
  • In OptionsPattern[{spec1,spec2,…}] the speci can be either heads fi or explicit rules opti->vali. Each head is treated as the list of rules obtained from Options[fi].
  • OptionsPattern[] uses the default options of the nearest enclosing function.
  • OptionsPattern[{}] includes no default options.

Examples

open all close all

Basic Examples  (3)

Define default option values for the function f:

Wolfram Language code: Options[f] = {a -> a0, b -> b0};

Define f, allowing options to be given:

Wolfram Language code: f[x_, OptionsPattern[]] := {x, OptionValue[a]}

Use f with an explicit option setting:

Wolfram Language code: f[7, a -> uuu]

Use f with options taken to have their default values:

Wolfram Language code: f[7]

Define default option values for this assignment without explicitly setting up Options[f]:

Wolfram Language code: f[x_, OptionsPattern[{a -> a0, b -> b0}]] := {x, OptionValue[a]}
Wolfram Language code: f[7]

Take default option values from Plot:

Wolfram Language code: f[x_, OptionsPattern[Plot]] := {OptionValue[AspectRatio], OptionValue[ImageSize]}

Use the defaults from Plot:

Wolfram Language code: f[7]

Override one of the defaults from Plot:

Wolfram Language code: f[7, ImageSize -> 20]

Scope  (4)

Use the options of ArcLength, but override the default value of Method:

Wolfram Language code: f[OptionsPattern[{Method -> "NIntegrate", ArcLength}]] := {OptionValue[Assumptions], OptionValue["Method"]}

Explicit option settings are honored:

Wolfram Language code: f[Assumptions -> c > 0, Method -> "Integrate"]

f uses the same default as ArcLength for Assumptions, but not Method:

Wolfram Language code: f[]
Wolfram Language code: OptionValue[ArcLength, {Assumptions, Method}]

Take options from both Plot and Plot3D:

Wolfram Language code: f[OptionsPattern[{Plot, Plot3D}]] := {OptionValue[PlotRange], OptionValue[BoxRatios]}

Give an explicit setting:

Wolfram Language code: f[PlotRange -> All]

For common options, the default is inherited from Plot:

Wolfram Language code: f[]
Wolfram Language code: Options[Plot, PlotRange]
Wolfram Language code: Options[Plot3D, PlotRange]

The function g inherits defaults for common options from Plot3D:

Wolfram Language code: g[OptionsPattern[{Plot3D, Plot}]] := {OptionValue[PlotRange], OptionValue[BoxRatios]}
Wolfram Language code: g[]

Use OptionsPattern with no default options:

Wolfram Language code: f[x_, OptionsPattern[{}]] := OptionValue[a]

Explicit uses of the option are honored:

Wolfram Language code: f[1, a -> x, b -> y]

The option name is returned if not explicitly present in the options:

Wolfram Language code: f[7, {b -> y}]

OptionsPattern can be used in normal pattern-matching functions like ReplaceAll:

Wolfram Language code: f[7, {a -> x, b -> y}] /. f[_, OptionsPattern[{}]] :> OptionValue[a]

Applications  (2)

Define the default option values for a function f:

Wolfram Language code: Options[f] = {"Square" -> False}

Implement f using a helper function fCore, but still inherit defaults from f:

Wolfram Language code: f[args___] := fCore[f, args] fCore[f, x_, OptionsPattern[f]] := If[OptionValue["Square"], x ^ 2, x, "BadOptionValue"]

The default option value of f is honored:

Wolfram Language code: f[2]

An explicit option settings takes precedence:

Wolfram Language code: f[2, "Square" -> True]

Define two functions with options:

Wolfram Language code: Options[f] = {a -> 1, b -> 2}; Options[g] = {b -> 3, c -> 4};

Define a function h that uses both sets of options, giving preference to the defaults of g:

Wolfram Language code: h[OptionsPattern[{g, f}]] := OptionValue[{a, b, c}]
Wolfram Language code: h[]
Wolfram Language code: h[a -> 10, b -> 7]

Properties & Relations  (3)

OptionsPattern matches any sequence of rules or lists of rules:

Wolfram Language code: MatchQ[f[a -> 1, b :> 3], f[OptionsPattern[]]]
Wolfram Language code: MatchQ[f[{a -> 1, b :> 3}], f[OptionsPattern[]]]
Wolfram Language code: MatchQ[f[{a -> 1, {b :> 3, {c -> 7}}}], f[OptionsPattern[]]]

An empty sequence matches OptionsPattern:

Wolfram Language code: MatchQ[f[], f[OptionsPattern[]]]

An empty list matches OptionsPattern:

Wolfram Language code: MatchQ[f[{}], f[OptionsPattern[]]]

Possible Issues  (2)

OptionsPattern will match any set of options:

Wolfram Language code: Options[f] = {a -> 1}; f[opts : OptionsPattern[f]] := {opts, OptionValue[a]}

This may cause messages if invalid options are passed:

Wolfram Language code: f[a -> 1, b -> 2]

FilterRules can be used to only use options valid for f:

Wolfram Language code: f[opts : OptionsPattern[f]] := {opts, OptionValue[f, FilterRules[Options[f], {opts}], a]}
Wolfram Language code: f[a -> 1, b -> 2]

Any nesting of empty lists will match OptionsPattern:

Wolfram Language code: MatchQ[f[{}], f[OptionsPattern[]]]
Wolfram Language code: MatchQ[f[{{}}], f[OptionsPattern[]]]

See Also

OptionValue  BlankSequence  Repeated  FilterRules  CheckArguments  ArgumentsOptions  KeyValuePattern

Tech Notes

    ▪
  • Patterns and Transformation Rules
  • ▪
  • Setting Up Functions with Optional Arguments
  • ▪
  • Manipulating Options

Related Guides

    ▪
  • Options Management
  • ▪
  • Package Development
  • ▪
  • Patterns
  • ▪
  • Robustness & Error Handling

Related Workflows

    Related Workflows
    ▪
  • Define a Function with Options

History

Introduced in 2007 (6.0)

Wolfram Research (2007), OptionsPattern, Wolfram Language function, https://reference.wolfram.com/language/ref/OptionsPattern.html.

Text

Wolfram Research (2007), OptionsPattern, Wolfram Language function, https://reference.wolfram.com/language/ref/OptionsPattern.html.

CMS

Wolfram Language. 2007. "OptionsPattern." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/OptionsPattern.html.

APA

Wolfram Language. (2007). OptionsPattern. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/OptionsPattern.html

BibTeX

@misc{reference.wolfram_2026_optionspattern, author="Wolfram Research", title="{OptionsPattern}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/OptionsPattern.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_optionspattern, organization={Wolfram Research}, title={OptionsPattern}, year={2007}, url={https://reference.wolfram.com/language/ref/OptionsPattern.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English