WOLFRAM

ToEntity[expr]

returns an entity object corresponding to the given expression.

ToEntity[expr,type]

returns an entity object of the specified type corresponding to expr.

Details

Examples

open allclose all

Basic Examples  (8)Summary of the most common use cases

Convert characters to entities:

Out[1]=1
Out[3]=3
Out[5]=5

Convert a molecule to an entity:

Out[1]=1
Out[2]=2

Convert colors to entities:

Out[1]=1
Out[3]=3

Convert undirected graphs to entities:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Use ToEntity for "MathematicalFunction" entity discovery:

Out[1]=1
Out[3]=3
Out[5]=5

Convert a quantity to a physical constant:

Out[1]=1
Out[2]=2

Convert a mathematical constant to an entity:

Out[1]=1
Out[2]=2

Convert a Wolfram Language symbol to an entity:

Out[1]=1
Out[2]=2
Out[3]=3

Scope  (7)Survey of the scope of standard use cases

"Character"  (1)

Convert a character to an entity:

Out[1]=1

Use FromCharacterCode:

Out[3]=3

"Color"  (1)

Convert a named Wolfram Language color to an entity:

Out[1]=1

Use a typeset form of a color:

Out[3]=3

"Graph"  (1)

Convert an explicitly constructed graph to an entity:

Out[1]=1

Use a graph from GraphData:

Out[2]=2

Use a graph constructor function:

Out[3]=3

Use a programmatically constructed graph:

Out[4]=4

"MathematicalFunction"  (1)

Convert a Mathematica special function to an entity:

Out[1]=1

Convert a Mathematica special function expression to an entity:

Out[3]=3

"PhysicalConstant"  (1)

Convert a quantity representing a physical constant to an entity:

Out[1]=1

Use a quantity with unit multiplier:

Out[3]=3

"PhysicalQuantity"  (1)

Convert a quantity variable to an entity:

Out[1]=1

"WolframLanguageSymbol"  (1)

Convert a Wolfram Language symbol to an entity:

Out[1]=1

Use a second argument to specify the type of entity desired:

Out[3]=3

Applications  (1)Sample problems that can be solved with this function

Verify that all small graphs in GraphData give entities with canonical names equivalent to their standard names:

Out[1]=1

Properties & Relations  (4)Properties of the function, and connections to other functions

For suitable graph entities, FromEntity can be used to effectively "reverse" ToEntity:

Out[1]=1
Out[2]=2
Out[3]=3

This is similar for suitable character entities:

Out[5]=5

When a GraphData standard name is known, ToEntity is equivalent to the GraphData "Entity" property:

Out[1]=1
Out[2]=2

The result of ToEntity is typically Entity["type","canonicalname"]:

Out[1]=1
Out[2]=2

The canonical name of a character entity is typically the value returned by ToCharacterCode:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Possible Issues  (3)Common pitfalls and unexpected behavior

Entities may not exist for all possible Wolfram Language objects of appropriate type:

Out[1]=1
Out[2]=2

Some inputs may have multiple representations available:

The second argument can be used to specify to which type the input should be converted:

Specifying different arguments to same symbol may result in different "MathematicalFunction" entities:

Out[1]=1
Out[2]=2
Out[3]=3

Neat Examples  (2)Surprising or curious use cases

Check that the following embeddings all correspond to the cubical graph:

Out[1]=1
Out[2]=2
Out[3]=3

Convert a range of special characters to entities:

Out[1]=1
Out[2]=2
Wolfram Research (2014), ToEntity, Wolfram Language function, https://reference.wolfram.com/language/ref/ToEntity.html (updated 2021).
Wolfram Research (2014), ToEntity, Wolfram Language function, https://reference.wolfram.com/language/ref/ToEntity.html (updated 2021).

Text

Wolfram Research (2014), ToEntity, Wolfram Language function, https://reference.wolfram.com/language/ref/ToEntity.html (updated 2021).

Wolfram Research (2014), ToEntity, Wolfram Language function, https://reference.wolfram.com/language/ref/ToEntity.html (updated 2021).

CMS

Wolfram Language. 2014. "ToEntity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ToEntity.html.

Wolfram Language. 2014. "ToEntity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ToEntity.html.

APA

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

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

BibTeX

@misc{reference.wolfram_2025_toentity, author="Wolfram Research", title="{ToEntity}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ToEntity.html}", note=[Accessed: 05-June-2025 ]}

@misc{reference.wolfram_2025_toentity, author="Wolfram Research", title="{ToEntity}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ToEntity.html}", note=[Accessed: 05-June-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_toentity, organization={Wolfram Research}, title={ToEntity}, year={2021}, url={https://reference.wolfram.com/language/ref/ToEntity.html}, note=[Accessed: 05-June-2025 ]}

@online{reference.wolfram_2025_toentity, organization={Wolfram Research}, title={ToEntity}, year={2021}, url={https://reference.wolfram.com/language/ref/ToEntity.html}, note=[Accessed: 05-June-2025 ]}