Convert ObjectID (Mongodb) to String in JavaScript

Try this:

objectId.str

See the doc.

ObjectId() has the following attribute and methods:

[…]

  • str – Returns the hexadecimal string representation of the object.

Leave a Comment