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
OptionValue
  • See Also
    • OptionsPattern
    • Options
    • AbsoluteOptions
    • FilterRules
    • Lookup
  • Related Guides
    • Options Management
    • Package Development
  • Workflows
    • Define a Function with Options
  • Tech Notes
    • Setting Up Functions with Optional Arguments
    • Manipulating Options
    • See Also
      • OptionsPattern
      • Options
      • AbsoluteOptions
      • FilterRules
      • Lookup
    • Related Guides
      • Options Management
      • Package Development
    • Workflows
      • Define a Function with Options
    • Tech Notes
      • Setting Up Functions with Optional Arguments
      • Manipulating Options

OptionValue[name]

gives the value of name in options matched by OptionsPattern.

OptionValue[f,name]

gives the value of name for options associated with the head f.

OptionValue[f,opts,name]

extracts option values from the explicit list of rules opts.

OptionValue[…,{name1,name2,…}]

extracts several 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
    • OptionsPattern
    • Options
    • AbsoluteOptions
    • FilterRules
    • Lookup
  • Related Guides
    • Options Management
    • Package Development
  • Workflows
    • Define a Function with Options
  • Tech Notes
    • Setting Up Functions with Optional Arguments
    • Manipulating Options
    • See Also
      • OptionsPattern
      • Options
      • AbsoluteOptions
      • FilterRules
      • Lookup
    • Related Guides
      • Options Management
      • Package Development
    • Workflows
      • Define a Function with Options
    • Tech Notes
      • Setting Up Functions with Optional Arguments
      • Manipulating Options

OptionValue

OptionValue[name]

gives the value of name in options matched by OptionsPattern.

OptionValue[f,name]

gives the value of name for options associated with the head f.

OptionValue[f,opts,name]

extracts option values from the explicit list of rules opts.

OptionValue[…,{name1,name2,…}]

extracts several option values.

Details

  • OptionValue[name] is equivalent to OptionValue[f,name], where f is the head of the left-hand side of the transformation rule in which OptionValue[name] appears.
  • OptionValue[f,name] and OptionValue[name] will use values from the first OptionsPattern object that appears as an argument of f.
  • In OptionValue[f,opts,name], only the explicit list opts and the defaults derived from f will be considered.
  • In OptionValue[f,opts,name], f can be a symbol, a rule, or a list of symbols and rules specifying default values. Each symbol s in f is equivalent to Options[s]. If the same option name is specified multiple times, the first specification determines the default.
  • OptionValue[f,opts,name,Hold] returns the option value with Hold wrapped around it.
  • OptionValue[Automatic,Automatic,name,Hold] is equivalent to OptionValue[name], except that the option value is returned with Hold wrapped around it.
  • OptionValue ignores contexts when comparing option names and treats the symbol s and the string SymbolName[s] interchangeably.

Examples

open all close all

Basic Examples  (1)

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]

Scope  (4)

Retrieve several option values at once:

Wolfram Language code: OptionValue[Plot, {Frame, PlotPoints}]

Use an explicit list of options:

Wolfram Language code: OptionValue[Plot, {PlotRange -> Full}, {PlotRange, PlotRangePadding}]

Define a transformation rule using multiple OptionsPattern constructs:

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

OptionValue[a] is treated as OptionValue[f,a] because it is the outer head:

Wolfram Language code: f[g[]]

OptionValue tracks where a particular option was specified:

Wolfram Language code: f[g[a -> 3], a -> 4]

Use Hold in the fourth argument to return the unevaluated forms of options using RuleDelayed:

Wolfram Language code: OptionValue[{Assumptions :> $Assumptions}, {}, Assumptions, Hold]

Without the Hold, the current value of $Assumptions would be returned:

Wolfram Language code: OptionValue[{Assumptions :> $Assumptions}, {}, Assumptions]

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 setting 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[opts : OptionsPattern[]] := OptionValue[{g, f}, {opts}, {a, b, c}]
Wolfram Language code: h[]
Wolfram Language code: h[a -> 10, b -> 7]

Properties & Relations  (4)

Contexts are ignored when comparing option names:

Wolfram Language code: OptionValue[{foo`a -> 1}, bar`a]

A string and a symbol are treated interchangeably:

Wolfram Language code: OptionValue[{opt -> 1}, "opt"]
Wolfram Language code: OptionValue[{"opt" -> 1}, opt]

OptionValue checks that all options requested appear in the defaults:

Wolfram Language code: OptionValue[{a -> 1}, {a, b}]

For simple cases, OptionValue[f,opts,name] is similar to name/.opts/.Options[f]:

Wolfram Language code: Options[f] = {a -> x, b -> y}
Wolfram Language code: OptionValue[f, {b -> 5}, {a, b}]
Wolfram Language code: {a, b} /. {b -> 5} /. Options[f]

However, OptionValue performs additional normalization to ensure rules are correctly applied:

Wolfram Language code: OptionValue[f, {a -> 7, b -> a}, {a, b}]
Wolfram Language code: {a, b} /. {a -> 7, b -> a} /. Options[f]

Possible Issues  (1)

Define a transformation rule where OptionsPattern only appears inside a different function:

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

OptionValue[a] does not work because OptionsPattern is not an argument of f:

Wolfram Language code: f[g[]]

See Also

OptionsPattern  Options  AbsoluteOptions  FilterRules  Lookup

Tech Notes

    ▪
  • Setting Up Functions with Optional Arguments
  • ▪
  • Manipulating Options

Related Guides

    ▪
  • Options Management
  • ▪
  • Package Development

Related Workflows

    Related Workflows
    ▪
  • Define a Function with Options

History

Introduced in 2007 (6.0)

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2026_optionvalue, organization={Wolfram Research}, title={OptionValue}, year={2007}, url={https://reference.wolfram.com/language/ref/OptionValue.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