← ConvertAPI

Convert Web URL to Specified Format with ConvertAPI API

Pipedream makes it easy to connect APIs for ConvertAPI and 2,500+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Convert Web URL to Specified Format with the ConvertAPI API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

Trusted by 1,000,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

Create a workflow to Convert Web URL to Specified Format with the ConvertAPI API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Convert Web URL to Specified Format action
    1. Connect your ConvertAPI account
    2. Configure URL
    3. Select a Format To
    4. Optional- Configure File Name
    5. Optional- Configure Timeout
    6. Optional- Configure Conversion Delay
    7. Optional- Configure Auth Username
    8. Optional- Configure Auth Password
    9. Optional- Configure Ad Block
    10. Optional- Configure Cookie Consent Block
    11. Optional- Configure Cookies
    12. Optional- Configure JavaScript
    13. Optional- Configure Wait Element
    14. Optional- Configure User JS
    15. Optional- Configure User CSS
    16. Optional- Configure Hide Elements
    17. Optional- Select a CSS Media Type
    18. Optional- Configure Image Width
    19. Optional- Configure Image Height
    20. Optional- Configure Image Quality
    21. Optional- Configure Crop Element
    22. Optional- Configure Crop X
    23. Optional- Configure Crop Y
    24. Optional- Configure Crop Width
    25. Optional- Configure Crop Height
    26. Optional- Configure Zoom
    27. Optional- Configure Load Lazy Content
    28. Optional- Configure Viewport Width
    29. Optional- Configure Viewport Height
    30. Optional- Configure Respect Viewport
    31. Optional- Configure Scale
    32. Optional- Select a Page Orientation
    33. Optional- Select a Page Size
    34. Optional- Configure Page Width
    35. Optional- Configure Page Height
    36. Optional- Configure Margin Top
    37. Optional- Configure Margin Right
    38. Optional- Configure Margin Bottom
    39. Optional- Configure Margin Left
    40. Optional- Configure Page Range
    41. Optional- Configure Background
    42. Optional- Select a Fixed Elements
    43. Optional- Configure ShowElements
    44. Optional- Configure Avoid Break Elements
    45. Optional- Configure Break Before Elements
    46. Optional- Configure Break After Elements
    47. Optional- Configure Compress PDF
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Convert Web URL to Specified Format with ConvertAPI API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + ConvertAPI
 
Try it
Convert Web URL to Specified Format with ConvertAPI API on New Submission from Typeform API
Typeform + ConvertAPI
 
Try it
Convert Web URL to Specified Format with ConvertAPI API on New Submission (Instant) from Jotform API
Jotform + ConvertAPI
 
Try it
Convert Web URL to Specified Format with ConvertAPI API on New Scheduled Tasks from Pipedream API
Pipedream + ConvertAPI
 
Try it
Convert Web URL to Specified Format with ConvertAPI API on New Download Counts from npm API
npm + ConvertAPI
 
Try it

Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Convert Web URL to Specified Format on ConvertAPI
Description:Converts a website page to a specified format. [See the documentation](https://v2.convertapi.com/info/openapi)
Version:0.0.1
Key:convertapi-convert-web-url

Code

import FormData from "form-data";
import {
  CSS_MEDIA_TYTPE_OPTIONS,
  FIXED_ELEMENTS_OPTIONS,
  FORMAT_TO_OPTIONS,
  PAGE_ORIENTATION_OPTIONS,
  PAGE_SIZE_OPTIONS,
} from "../../common/constants.mjs";
import { saveFile } from "../../common/utils.mjs";
import convertapi from "../../convertapi.app.mjs";

export default {
  key: "convertapi-convert-web-url",
  name: "Convert Web URL to Specified Format",
  description: "Converts a website page to a specified format. [See the documentation](https://v2.convertapi.com/info/openapi)",
  version: "0.0.1",
  type: "action",
  props: {
    convertapi,
    url: {
      type: "string",
      label: "URL",
      description: "The website URL to be converted to a specified format.",
    },
    formatTo: {
      type: "string",
      label: "Format To",
      description: "The format you want to convert the URL to.",
      options: FORMAT_TO_OPTIONS,
    },
    fileName: {
      type: "string",
      label: "File Name",
      description: "Converted output file name without extension. The extension will be added automatically.",
      optional: true,
    },
    timeout: {
      type: "string",
      label: "Timeout",
      description: "Conversion timeout in seconds.",
      optional: true,
    },
    conversionDelay: {
      type: "integer",
      label: "Conversion Delay",
      description: "Delay in seconds before page load and file creation. Sometimes useful to let web page fully load.",
      optional: true,
    },
    authUsername: {
      type: "string",
      label: "Auth Username",
      description: "HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication.",
      optional: true,
    },
    authPassword: {
      type: "string",
      label: "Auth Password",
      description: "HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication.",
      optional: true,
    },
    adBlock: {
      type: "boolean",
      label: "Ad Block",
      description: "Block ads in converting page.",
      optional: true,
    },
    cookieConsentBlock: {
      type: "boolean",
      label: "Cookie Consent Block",
      description: "Tries to remove EU regulation required cookie warnings from web pages.",
      optional: true,
    },
    cookies: {
      type: "string",
      label: "Cookies",
      description: "Set additional cookies for the page request. Exaple: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3",
      optional: true,
    },
    javaScript: {
      type: "boolean",
      label: "JavaScript",
      description: "Allow web pages to run JavaScript.",
      optional: true,
    },
    waitElement: {
      type: "string",
      label: "Wait Element",
      description: "Element selector string of the DOM element. Converter will wait for this element to appear in DOM before conversion begins.",
      optional: true,
    },
    userJs: {
      type: "string",
      label: "User JS",
      description: "Execute provided JavaScript before conversion begins.",
      optional: true,
    },
    userCss: {
      type: "string",
      label: "User CSS",
      description: "Apply additional CSS before conversion begins.",
      optional: true,
    },
    hideElements: {
      type: "string",
      label: "Hide Elements",
      description: "Element selector string of the DOM elements that need to be hidden during conversion.",
      optional: true,
    },
    cssMediaType: {
      type: "string",
      label: "CSS Media Type",
      description: "Use CSS media type in conversion process.",
      options: CSS_MEDIA_TYTPE_OPTIONS,
      optional: true,
      default: "screen",
    },
    imageWidth: {
      type: "integer",
      label: "Image Width",
      description: "Image width in pixels.",
      hidden: true,
      optional: true,
    },
    imageHeight: {
      type: "integer",
      label: "Image Height",
      description: "Image height in pixels.",
      hidden: true,
      optional: true,
    },
    imageQuality: {
      type: "integer",
      label: "Image Quality",
      description: "Set output image quality.",
      default: 75,
      hidden: true,
      optional: true,
    },
    cropElement: {
      type: "string",
      label: "Crop Element",
      description: "Element selector string of the DOM element that should be converted. Element will be cropped from the document.",
      hidden: true,
      optional: true,
    },
    cropX: {
      type: "integer",
      label: "Crop X",
      description: "Screenshot crop X offset.",
      hidden: true,
      optional: true,
    },
    cropY: {
      type: "integer",
      label: "Crop Y",
      description: "Screenshot crop Y offset.",
      hidden: true,
      optional: true,
    },
    cropWidth: {
      type: "integer",
      label: "Crop Width",
      description: "Screenshot crop width.",
      hidden: true,
      optional: true,
    },
    cropHeight: {
      type: "integer",
      label: "Crop Height",
      description: "Screenshot crop height.",
      hidden: true,
      optional: true,
    },
    zoom: {
      type: "integer",
      label: "Zoom",
      description: "Set the default zoom level of webpages.",
      hidden: true,
      optional: true,
    },
    loadLazyContent: {
      type: "boolean",
      label: "Load Lazy Content",
      description: "Load page images that loads only when they are visible.",
      hidden: true,
      optional: true,
    },
    viewportWidth: {
      type: "integer",
      label: "Viewport Width",
      description: "Sets browser viewport width.",
      hidden: true,
      default: 1366,
      optional: true,
    },
    viewportHeight: {
      type: "integer",
      label: "Viewport Height",
      description: "Sets browser viewport height.",
      hidden: true,
      default: 1024,
      optional: true,
    },
    respectViewport: {
      type: "boolean",
      label: "Respect Viewport",
      description: "If true, the converter will generate PDF as the content looks like in the browser. If is set to false, the converter acts like Chrome print to PDF function.",
      hidden: true,
      optional: true,
    },
    scale: {
      type: "integer",
      label: "Scale",
      description: "Set web page scale value in percentage.",
      hidden: true,
      default: 100,
      optional: true,
    },
    pageOrientation: {
      type: "string",
      label: "Page Orientation",
      description: "PDF page orientation",
      hidden: true,
      options: PAGE_ORIENTATION_OPTIONS,
      optional: true,
    },
    pageSize: {
      type: "string",
      label: "Page Size",
      description: "PDF Page Size",
      hidden: true,
      options: PAGE_SIZE_OPTIONS,
      optional: true,
    },
    pageWidth: {
      type: "integer",
      label: "Page Width",
      description: "Custom page width in millimeters (mm). This option override PageSize option.",
      hidden: true,
      optional: true,
    },
    pageHeight: {
      type: "integer",
      label: "Page Height",
      description: "Custom page height in millimeters (mm). This option override PageSize option.",
      hidden: true,
      optional: true,
    },
    marginTop: {
      type: "integer",
      label: "Margin Top",
      description: "Set the page top margin in millimeters (mm).",
      hidden: true,
      optional: true,
    },
    marginRight: {
      type: "integer",
      label: "Margin Right",
      description: "Set the page right margin in millimeters (mm).",
      hidden: true,
      optional: true,
    },
    marginBottom: {
      type: "integer",
      label: "Margin Bottom",
      description: "Set the page bottom margin in millimeters (mm).",
      hidden: true,
      optional: true,
    },
    marginLeft: {
      type: "integer",
      label: "Margin Left",
      description: "Set the page left margin in millimeters (mm).",
      hidden: true,
      optional: true,
    },
    pageRange: {
      type: "string",
      label: "Page Range",
      description: "Set page range. Example 1-10 or 1,2,5.",
      hidden: true,
      optional: true,
    },
    background: {
      type: "boolean",
      label: "Background",
      description: "Convert web page background.",
      hidden: true,
      optional: true,
    },
    fixedElements: {
      type: "string",
      label: "Fixed Elements",
      description: "Change fixed elements CSS 'position' property to adapt page for conversion",
      options: FIXED_ELEMENTS_OPTIONS,
      hidden: true,
      optional: true,
    },
    showElements: {
      type: "string",
      label: "ShowElements",
      description: "Element selector string of the DOM elements that should be visible during conversion. Other elements will be hidden.",
      hidden: true,
      optional: true,
    },
    avoidBreakElements: {
      type: "string",
      label: "Avoid Break Elements",
      description: "CSS selector for the elements that pages should not break.",
      hidden: true,
      optional: true,
    },
    breakBeforeElements: {
      type: "string",
      label: "Break Before Elements",
      description: "CSS selector for the elements that should apply page break before it.",
      hidden: true,
      optional: true,
    },
    breakAfterElements: {
      type: "string",
      label: "Break After Elements",
      description: "CSS selector for the elements that should apply page break after it.",
      hidden: true,
      optional: true,
    },
    compressPDF: {
      type: "boolean",
      label: "Compress PDF",
      description: "It tries to produce smaller output files but requires Adobe Reader 6, released in 2003 or newer, to view created PDF files.",
      hidden: true,
      optional: true,
    },
  },
  async additionalProps(props) {
    const isJpg = this.formatTo === "jpg";

    props.imageWidth.hidden = !isJpg;
    props.imageHeight.hidden = !isJpg;
    props.type.hidden = !isJpg;
    props.cropElement.hidden = !isJpg;
    props.cropX.hidden = !isJpg;
    props.cropY.hidden = !isJpg;
    props.cropWidth.hidden = !isJpg;
    props.cropHeight.hidden = !isJpg;
    props.zoom.hidden = !isJpg;

    props.loadLazyContent.hidden = isJpg;
    props.viewportWidth.hidden = isJpg;
    props.viewportHeight.hidden = isJpg;
    props.respectViewport.hidden = isJpg;
    props.scale.hidden = isJpg;
    props.pageOrientation.hidden = isJpg;
    props.pageSize.hidden = isJpg;
    props.pageWidth.hidden = isJpg;
    props.pageHeight.hidden = isJpg;
    props.marginTop.hidden = isJpg;
    props.marginRight.hidden = isJpg;
    props.marginBottom.hidden = isJpg;
    props.marginLeft.hidden = isJpg;
    props.pageRange.hidden = isJpg;
    props.background.hidden = isJpg;
    props.fixedElements.hidden = isJpg;
    props.showElements.hidden = isJpg;
    props.avoidBreakElements.hidden = isJpg;
    props.breakBeforeElements.hidden = isJpg;
    props.breakAfterElements.hidden = isJpg;
    props.compressPDF.hidden = isJpg;

    return {};
  },
  async run({ $ }) {
    try {
      const data = new FormData();

      data.append("Url", this.url);
      if (this.fileName) data.append("FileName", this.fileName);
      if (this.timeout) data.append("Timeout", this.timeout);
      if (this.conversionDelay) data.append("ConversionDelay", this.conversionDelay);
      if (this.authUsername) data.append("AuthUsername", this.authUsername);
      if (this.authPassword) data.append("AuthPassword", this.authPassword);
      if (this.adBlock) data.append("AdBlock", `${this.adBlock}`);
      if (this.cookieConsentBlock) data.append("CookieConsentBlock", `${this.cookieConsentBlock}`);
      if (this.cookies) data.append("Cookies", this.cookies);
      if (this.javaScript) data.append("JavaScript", `${this.javaScript}`);
      if (this.waitElement) data.append("WaitElement", this.waitElement);
      if (this.userJs) data.append("UserJs", this.userJs);
      if (this.userCss) data.append("UserCss", this.userCss);
      if (this.hideElements) data.append("HideElements", this.hideElements);
      if (this.cssMediaType) data.append("CssMediaType", this.cssMediaType);

      if (this.formatTo === "jpg") {
        if (this.imageWidth) data.append("ImageWidth", this.imageWidth);
        if (this.imageHeight) data.append("ImageHeight", this.imageHeight);
        if (this.type) data.append("Type", this.type);
        if (this.cropElement) data.append("CropElement", this.cropElement);
        if (this.cropX) data.append("CropX", this.cropX);
        if (this.cropY) data.append("CropY", this.cropY);
        if (this.cropWidth) data.append("CropWidth", this.cropWidth);
        if (this.cropHeight) data.append("CropHeight", this.cropHeight);
        if (this.zoom) data.append("Zoom", this.zoom);
      } else {
        if (this.loadLazyContent) data.append("LoadLazyContent", `${this.loadLazyContent}`);
        if (this.viewportWidth) data.append("ViewportWidth", this.viewportWidth);
        if (this.viewportHeight) data.append("ViewportHeight", this.viewportHeight);
        if (this.respectViewport) data.append("RespectViewport", `${this.respectViewport}`);
        if (this.scale) data.append("Scale", this.scale);
        if (this.pageOrientation) data.append("PageOrientation", this.pageOrientation);
        if (this.pageSize) data.append("PageSize", this.pageSize);
        if (this.pageWidth) data.append("PageWidth", this.pageWidth);
        if (this.pageHeight) data.append("PageHeight", this.pageHeight);
        if (this.marginTop) data.append("MarginTop", this.marginTop);
        if (this.marginRight) data.append("MarginRight", this.marginRight);
        if (this.marginBottom) data.append("MarginBottom", this.marginBottom);
        if (this.marginLeft) data.append("MarginLeft", this.marginLeft);
        if (this.pageRange) data.append("PageRange", this.pageRange);
        if (this.background) data.append("Background", `${this.background}`);
        if (this.fixedElements) data.append("FixedElements", this.fixedElements);
        if (this.showElements) data.append("ShowElements", this.showElements);
        if (this.avoidBreakElements) data.append("AvoidBreakElements", this.avoidBreakElements);
        if (this.breakBeforeElements) data.append("BreakBeforeElements", this.breakBeforeElements);
        if (this.breakAfterElements) data.append("BreakAfterElements", this.breakAfterElements);
        if (this.compressPDF) data.append("CompressPDF", `${this.compressPDF}`);
      }

      const { Files } = await this.convertapi.convertWebToFormat({
        $,
        formatTo: this.formatTo,
        data,
        headers: data.getHeaders(),
        timeout: this.timeout ? 2000 * Number(this.timeout) : undefined,
      });

      await saveFile(Files);
      const filename = Files[0].FileName;

      $.export("$summary", `Successfully converted URL to ${this.formatTo} and saved in /tmp directory as **${filename}**.`);
      return {
        filepath: `/tmp/${filename}`,
      };
    } catch (e) {
      throw new Error(e);
    }
  },
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
ConvertAPIconvertapiappThis component uses the ConvertAPI app.
URLurlstring

The website URL to be converted to a specified format.

Format ToformatTostringSelect a value from the drop down menu:jpgpdf
File NamefileNamestring

Converted output file name without extension. The extension will be added automatically.

Timeouttimeoutstring

Conversion timeout in seconds.

Conversion DelayconversionDelayinteger

Delay in seconds before page load and file creation. Sometimes useful to let web page fully load.

Auth UsernameauthUsernamestring

HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication.

Auth PasswordauthPasswordstring

HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication.

Ad BlockadBlockboolean

Block ads in converting page.

Cookie Consent BlockcookieConsentBlockboolean

Tries to remove EU regulation required cookie warnings from web pages.

Cookiescookiesstring

Set additional cookies for the page request. Exaple: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3

JavaScriptjavaScriptboolean

Allow web pages to run JavaScript.

Wait ElementwaitElementstring

Element selector string of the DOM element. Converter will wait for this element to appear in DOM before conversion begins.

User JSuserJsstring

Execute provided JavaScript before conversion begins.

User CSSuserCssstring

Apply additional CSS before conversion begins.

Hide ElementshideElementsstring

Element selector string of the DOM elements that need to be hidden during conversion.

CSS Media TypecssMediaTypestringSelect a value from the drop down menu:printscreen

Authentication

ConvertAPI uses API keys for authentication. When you connect your ConvertAPI account, Pipedream securely stores the keys so you can easily authenticate to ConvertAPI APIs in both code and no-code steps.

You can get your API Secret on your Profile Page under the Authentication section on the left sidebar.

About ConvertAPI

ConvertAPI is a high-performance online files conversion and manipulation service for developers. It can be integrated into any application or platform in just a few minutes, scales up to handle any amount of traffic, uses little resources and supports 200+ conversion actions.

More Ways to Use ConvertAPI

Actions

Convert Base64 Encoded File with the ConvertAPI API

This action converts a base64-string-encoded file into the user-specified format. See the documentation

 
Try it
Convert File with the ConvertAPI API

Use this action to convert files to the chosen format. See the documentation

 
Try it

Explore Other Apps

1
-
24
of
2,500+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Pipedream Utils
Pipedream Utils
Utility functions to use within your Pipedream workflows
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Premium
Salesforce
Salesforce
Cloud-based customer relationship management (CRM) platform that helps businesses manage sales, marketing, customer support, and other business activities, ultimately aiming to improve customer relationships and streamline operations.
Premium
HubSpot
HubSpot
HubSpot's CRM platform contains the marketing, sales, service, operations, and website-building software you need to grow your business.
Premium
Zoho CRM
Zoho CRM
Zoho CRM is an online Sales CRM software that manages your sales, marketing, and support in one CRM platform.
Premium
Stripe
Stripe
Stripe powers online and in-person payment processing and financial solutions for businesses of all sizes.
Shopify
Shopify
Shopify is a complete commerce platform that lets anyone start, manage, and grow a business. You can use Shopify to build an online store, manage sales, market to customers, and accept payments in digital and physical locations.
Premium
WooCommerce
WooCommerce
WooCommerce is the open-source ecommerce platform for WordPress.
Premium
Snowflake
Snowflake
A data warehouse built for the cloud
Premium
MongoDB
MongoDB
MongoDB is an open source NoSQL database management program.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
Premium
AWS
AWS
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Premium
Twilio SendGrid
Twilio SendGrid
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Premium
Klaviyo
Klaviyo
Email Marketing and SMS Marketing Platform
Premium
Zendesk
Zendesk
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
Premium
ServiceNow
ServiceNow
The smarter way to workflow
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.