how to generate link preview in your webapp

What is link preview? Let me show you instead of explaining. Have a look at these images below.

link preview example

one more

link preview example 2

You get it already right? Its a small preview that is generated when we share a link on social media sites like Facebook, WhatsApp, twitter etc. It contains title, description and a thumbnail of one of the images in that link or main logo.

how to get link preview?

Developers need link previews when they are developing any social sharing app or any other app that involves sharing links. So let’s see how to get them.

Link previews are usually generated by fetching the URL and parsing meta tags of the page for title and description and image tags for thumbnails. This can be done by making basic GET requests to the URL. This method works when we just want to parse the meta tags and the page is rendered on the server.

If we want to parse description from the content of the page and the content is rendered client side (ex: An AngularJS app) then we should use different methods like using a headless browser such as phantomJS to render the page and fetch data from it.

We need a server to fetch data in any of the above-mentioned methods. Anyway, I’ll be explaining how to do that in another post in detail. This post is all about how to simplify the process using a free link preview service.

Free link preview service is a Free REST API service which takes any URL as input and sends back JSON response with title, description and thumbnail.

All you need to do is send a request to their API with the URL for which link preview has to be generated.

Here’s an example request (GET)

Here’s a sample response

link preview sample response

Jquery cross origin jsonp request

var target = '';
url: "",
dataType: 'jsonp',
data: {q: target, key: 123456},
success: function (response) {

Wrapping up

Once we get the JSON response, parse it and style it as per your requirement in your webapp. Create an account in, grab an API key and start generating link previews!

If you have any questions or feedback, comment below.

0 0 vote
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
Mika Kaakinen
Mika Kaakinen
4 years ago

Thank you for your good tutorials Ranjith!

4 years ago

Thank you! LinkPreview is awesome!

Curious Programmer
Curious Programmer
3 years ago

Is there a way to do this without using a third party service?

Anthony Nahas
2 years ago

I developed recently an angular v6 open source UI library to preview links!

check this out! Feedback are really appreciated โค

the demo app can be found here:

2 years ago

Anyone tried doing this with mobile app??

Abijith Ajayan
2 years ago

Its not working with Angularjs. Kindly please helpโ€ฆ

2 years ago

Im getting g 401 error

Lisa Douris
1 year ago

Help with Link preview for

6 days ago

How can I share other website-specific content on my website as we share some links on social and show a preview of that site?