URL to JPEG with GoLang

Screenshot webpages as JPEG with GoLang

No browser management required

Capture public webpages from GoLang with the github.com/htmlcsstoimage/go-client Go module without installing Chrome, running chromedp or Rod, or maintaining screenshot storage and delivery.

  • No browser processes to maintain
  • Full-page and selector controls included
  • Complete GoLang request below
Real URL screenshot API requests followed by their rendered webpage images.
Request
POST https://hcti.io/v1/image
{
"url": "https://google.com",
"format": "jpeg",
"viewport_height": 480,
"viewport_width": 640
}
https://google.com
Screenshot of Google in a small viewport

GoLang workflow

Test the webpage capture before adding it to GoLang

Choose the URL and browser state here, then use the GoLang example below instead of rebuilding the screenshot workflow locally.

Loading playground…

Managed screenshots

Skip the fragile parts of native GoLang screenshot automation

Keep the application code focused on the request and response while HCTI manages Chromium, page loading, render isolation, retries, and hosted output.

No browser runtime to maintain

Keep the deployment as a small Go service instead of adding Chrome and a browser-controller process to the runtime.

Screenshot controls are already modeled

Set the viewport, full-page mode, selector, timing, color scheme, and browser state as request parameters instead of browser scripts.

A usable image URL immediately

Receive the hosted .jpeg result without building a separate pipeline for temporary files, uploads, storage, and delivery.

URL screenshot API

Send one GoLang request instead of running a browser

POST the webpage URL, capture settings, and format from GoLang. HCTI handles the browser lifecycle and returns the generated .jpeg URL.

  • Public webpage URL

    Send the URL to load, including webpages whose final state depends on browser-rendered JavaScript.

  • JPEG output

    Set format to jpeg and use the hosted .jpeg URL returned by the API.

  • Viewport and crop controls

    Set viewport dimensions, capture the full page, or crop the result to a CSS selector.

  • Browser environment

    Choose color scheme, timezone, mobile behavior, timing, and other page-loading controls.

POST https://hcti.io/v1/image request example.
Request
POST https://hcti.io/v1/image
{
"url": "https://example.com",
"format": "jpeg",
"viewport_width": 1200,
"viewport_height": 630
}

How it works

From webpage URL to a finished JPEG

  1. Send the webpage URL

    Submit a public URL with format set to jpeg and any viewport, selector, or browser settings.

  2. Chromium loads the page

    The API runs the webpage, styles, fonts, images, and JavaScript in a managed browser environment.

  3. Use the .jpeg URL

    Embed the hosted result, download the file, or save it in your own storage and application records.

Example code

Screenshot a webpage as JPEG in GoLang

Copy a complete GoLang request. Authentication, the webpage URL, viewport settings, output format, and response handling are shown together.

Official HCTI Go client · github.com/htmlcsstoimage/go-client

go get github.com/htmlcsstoimage/go-client
// go get github.com/htmlcsstoimage/go-client (Go 1.21+)
package main

import (
    "context"
    "fmt"

    "github.com/htmlcsstoimage/go-client"
)

func main() {
    // Uses HCTI_API_ID and HCTI_API_KEY from the environment.
    client, err := hcti.NewClientFromEnv()
    if err != nil {
        panic(err)
    }

    request := hcti.URLImageRequest{}
    request.URL = "https://example.com"
    request.Format = "jpg"
    request.ViewportHeight = hcti.Ptr(630)
    request.ViewportWidth = hcti.Ptr(1200)

    result, err := client.CreateImage(context.Background(), request)
    if err != nil {
        panic(err)
    }
    fmt.Println(result.URL)
}

Ready to capture?

Take your first JPEG webpage screenshot

Send a public URL to the API and receive a hosted .jpeg image without running browser infrastructure.