Contents
  1. The short answer
  2. Step by step: getting the code from an existing SVG file
  3. Option 1: Open it in a text editor
  4. Option 2: Use a web browser
  5. Option 3: Copy or export from a vector design application
  6. What the code should look like
  7. Verify the result before you use it
  8. Before reusing a logo

The short answer

An SVG file is already code. SVG (Scalable Vector Graphics) is a text-based format that describes shapes, paths, colors and text as XML markup. To get the code, open the .svg file in any plain-text editor and copy what you see, or use your design tool's copy-as-SVG or export function. If your logo exists only as a PNG, JPG or other raster image, there is no SVG code to extract. In that case the artwork has to be redrawn or traced as vectors first.

A few terms help define the scope. A vector is artwork built from mathematically defined points and curves, so it scales without losing sharpness. A path is the basic SVG shape element: a series of drawing commands stored in a d attribute. The viewBox is the coordinate system the artwork is drawn in, which controls how it scales to fit any width and height.

Step by step: getting the code from an existing SVG file

Option 1: Open it in a text editor

  • Locate the .svg file and make a copy, so the original stays untouched.
  • Right-click the copy and open it with a plain-text or code editor rather than an image viewer.
  • The file opens as markup that begins with an opening svg tag, sometimes preceded by an XML declaration or a comment left by the exporting software.
  • Select all and copy. You now have the full SVG code.

Option 2: Use a web browser

  • Drag the .svg file into a browser window, or open it from the browser's file menu.
  • Use the browser's view-source command to see the raw markup.
  • If the logo is already embedded inline on a web page you are authorized to work with, right-click it and choose Inspect. The developer tools show the svg element, and you can copy it from there.

Option 3: Copy or export from a vector design application

  • Adobe Illustrator: export or save the artwork as SVG. Recent versions also let you copy selected objects and paste them into a text editor as SVG markup.
  • Inkscape: Inkscape's native files are SVG. Saving as Plain SVG drops Inkscape-specific metadata. The built-in XML Editor shows the code for each element.
  • Figma: right-click a selected frame or layer and use the copy-as-SVG option to put the markup on your clipboard.

Menu names and export settings vary between software versions, and this guide was not given version-specific documentation to confirm them. Treat these as general locations and check your application's help if a label differs.

What the code should look like

The simplified example below shows the typical structure. The path data is a placeholder, not a real logo. A standalone SVG file normally also carries an xmlns attribute on the root svg element to declare the SVG namespace. Exporting software adds this automatically, so keep it when you copy code from a file.

<svg viewBox="0 0 200 80" width="200" height="80">
  <title>Brand logo</title>
  <path d="M10 10 H190 V70 H10 Z" fill="#1A1A1A"/>
  <path d="..." fill="#E04E39"/>
</svg>

Verify the result before you use it

A .svg extension does not prove the artwork is clean, editable vector work. Check the code for these points:

  • Embedded images: look for image elements, especially ones containing long base64 data strings. These mean a raster picture has been wrapped inside the SVG. It will blur when scaled and cannot be edited as shapes.
  • Live text versus outlines: text elements depend on the named font being available wherever the logo is shown. If the font is missing, the logo will render in a substitute font. For logo delivery, letterforms are usually converted to paths (outlined). This is a common recommendation, not a requirement of the format.
  • A viewBox on the root element: without one, the logo may not scale predictably in responsive layouts.
  • Rendering: paste the code into a blank HTML file, or open the saved file in a browser, and compare it with the original artwork at both small and large sizes.
  • Extra markup: editor metadata, unused definitions and empty groups are harmless but add weight. An SVG optimization tool can remove them. Re-check the rendering afterward, because aggressive settings can alter shapes or IDs.

Being able to see or copy SVG code does not grant permission to use the logo. Confirm that you own the artwork or have the brand owner's authorization before reusing, editing or redistributing it.