ToEntity
Details
- ToEntity evaluates for Wolfram Language expressions corresponding to entities of type "Character", "Chemical", "Color", "Graph", "MathematicalFunction", "PhysicalConstant", "PhysicalQuantity" and "WolframLanguageSymbol".
Examples
open all close allBasic Examples (2)
Convert a molecule to an entity:
molecule = Molecule[{"O", "H", "H"}, {Bond[{1, 2}, "Single"], Bond[{1, 3}, "Single"]}]ToEntity[molecule]ToEntity[RGBColor[1, 0, 0]]InputForm[%]ToEntity[RGBColor[0, 1, 0]]InputForm[%]Scope (9)
"Character" (2)
Convert a character to an entity:
ToEntity["α"]InputForm[%]Use FromCharacterCode:
ToEntity[FromCharacterCode[945]]Convert characters to entities:
ToEntity["δ"]InputForm[%]ToEntity["☂"]InputForm[%]ToEntity[FromCharacterCode[12345]]InputForm[%]"Color" (1)
"Graph" (1)
Convert an explicitly constructed graph to an entity:
ToEntity[Graph[{12, 23, 34}]]Use a graph from GraphData:
ToEntity[GraphData["DodecahedralGraph"]]Use a graph constructor function:
ToEntity[PetersenGraph[]]Use a programmatically constructed graph:
ToEntity[LineGraph[PetersenGraph[]]]"MathematicalFunction" (2)
Convert a Mathematica special function to an entity:
ToEntity[BesselJ, "MathematicalFunction"]InputForm[%]Convert a Mathematica special function expression to an entity:
ToEntity[ProductLog[x], "MathematicalFunction"]Use ToEntity for "MathematicalFunction" entity discovery:
ToEntity[Cos, "MathematicalFunction"]InputForm[%]ToEntity[Sin[x], "MathematicalFunction"]InputForm[%]ToEntity[ArcTan[x, y], "MathematicalFunction"]InputForm[%]"PhysicalConstant" (1)
"PhysicalQuantity" (1)
"WolframLanguageSymbol" (1)
Applications (1)
Verify that all small graphs in GraphData give entities with canonical names equivalent to their standard names:
Select[GraphData[ ;; 20], CanonicalName[ToEntity[GraphData[#]]] =!= #&]Properties & Relations (4)
For suitable graph entities, FromEntity can be used to effectively "reverse" ToEntity:
CompleteGraph[{3, 3}]ToEntity[%]FromEntity[%]This is similar for suitable character entities:
ToEntity["σ"]//InputFormFromEntity[%]When a GraphData standard name is known, ToEntity is equivalent to the GraphData "Entity" property:
ToEntity[GraphData["CoxeterGraph"]]GraphData["CoxeterGraph", "Entity"]The result of ToEntity is typically Entity["type","canonicalname"]:
Entity["Graph", "PetersenGraph"]ToEntity[GraphData["PetersenGraph"]]The canonical name of a character entity is typically the value returned by ToCharacterCode:
ToEntity["Θ"]CanonicalName[%]ToCharacterCode["Θ"]{CanonicalName[ToEntity["☂"]], ToCharacterCode["☂"]}Possible Issues (3)
Entities may not exist for all possible Wolfram Language objects of appropriate type:
ToEntity[CompleteGraph[10]]ToEntity[CompleteGraph[50]]Some inputs may have multiple representations available:
ToEntity[Red]//InputFormToEntity[BesselJ]//InputFormThe second argument can be used to specify to which type the input should be converted:
ToEntity[Red, "WolframLanguageSymbol"]//InputFormToEntity[BesselJ, "MathematicalFunction"]//InputFormSpecifying different arguments to same symbol may result in different "MathematicalFunction" entities:
ToEntity[HermiteH, "MathematicalFunction"]ToEntity[HermiteH[2, x], "MathematicalFunction"]ToEntity[HermiteH[2 + 3I, x], "MathematicalFunction"]Neat Examples (2)
Check that the following embeddings all correspond to the cubical graph:
Show[#, ImageSize -> {100, 100}]& /@ (cubes = GraphData["CubicalGraph", "Graph", "All"])ToEntity /@ cubesSameQ@@%Convert a range of special characters to entities:
With[{a = ToCharacterCode["a"]}, CharacterRange@@(FromCharacterCode[a + #]& /@ {100, 200})]ToEntity /@ %Related Guides
Text
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.
APA
Wolfram Language. (2014). ToEntity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ToEntity.html
BibTeX
@misc{reference.wolfram_2026_toentity, author="Wolfram Research", title="{ToEntity}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ToEntity.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_toentity, organization={Wolfram Research}, title={ToEntity}, year={2021}, url={https://reference.wolfram.com/language/ref/ToEntity.html}, note=[Accessed: 13-June-2026]}