<p>Use bitcoinJS's <a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/27a840aac4a12338f1e40c54f3759bbd7a559944/src/address.js#L101" rel="nofollow noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib/blob/27a840aac4a12338f1e40c54f3759bbd7a559944/src/address.js#L101</a> toOutputScript function in a try-catch block</p>

CC BY-SA 4.0
2021-05-26T17:14:15.310Z
Looks fine but I can't load the script address.js `Uncaught ReferenceError: exports is not defined`. Have you used it before?
Alejandro Veintimilla
CC BY-SA 4.0
2021-05-26T17:27:03.187Z
Here's an example: https://github.com/ilyavf/tx-builder/blob/4185f6c9614832b67d087eb561237e4dd3883e76/src/tx-builder.js#L9-L84
MCCCS
CC BY-SA 4.0
2021-05-21T16:53:54.037Z
2021-05-21T16:53:54.037Z
MCCCS
<p>I know there is a similar question but its 7 years old and the answer doesn't work. Now, many things have changed, including the addresses themselves. So, is there a js library I can trust that can validate addresses on 2021</p>

<address>
Validate Bitcoin address using Javascript
Alejandro Veintimilla
# Validate Bitcoin address using Javascript

(Asked by: username_0 on 2021-05-21)

I know there is a similar question but its 7 years old and the answer doesn't work. Now, many things have changed, including the addresses themselves. So, is there a js library I can trust that can validate addresses on 2021

**Tags:** address


---

## 1 answers

### Answer by username_1 on 2021-05-21. Score: 2

Use bitcoinJS's <https://github.com/bitcoinjs/bitcoinjs-lib/blob/27a840aac4a12338f1e40c54f3759bbd7a559944/src/address.js#L101> toOutputScript function in a try-catch block

> **Comments:**
> **username_0**: Looks fine but I can't load the script address.js `Uncaught ReferenceError: exports is not defined`. Have you used it before?  
> **username_1**: Here's an example: https://github.com/ilyavf/tx-builder/blob/4185f6c9614832b67d087eb561237e4dd3883e76/src/tx-builder.js#L9-L84  

---

