How to Save SVG Code as a Logo File
Turn copied SVG code into a working .svg logo file: save it as plain text, fix common breakages, and check that the result is clean, scalable vector artwork.
Contents
The short answer
SVG code is already the file. An SVG (Scalable Vector Graphics) file is a plain-text document written in XML markup that describes shapes as mathematical paths rather than pixels. To turn copied code into a logo file, paste it into a plain-text editor, save it with the .svg extension and UTF-8 encoding, and open the result in a browser or vector editor to confirm it renders. No conversion software is required. The rest of this guide covers how to do that reliably and how to check that the file is usable logo artwork rather than just something that displays.
Some terms used below: a path is a vector outline defined by points and curves. The viewBox is the attribute on the opening svg tag that sets the drawing's internal coordinate area, which lets the logo scale to any size without distortion. Outlined text means lettering that has been converted from live, font-dependent text into fixed paths.
Step-by-step: saving the code to a file
- 1. Copy the complete SVG code, from the opening svg tag to the closing svg tag. If the code begins with an XML declaration line, include it too.
- 2. Open a plain-text editor. On Windows, Notepad works. On macOS, TextEdit works only after switching the document to plain text through the Format menu; otherwise it saves rich text. Code editors also work.
- 3. Paste the code without changes.
- 4. Choose Save As, name the file with the .svg extension (for example, logo.svg), and select UTF-8 as the encoding if the editor offers the option.
- 5. If the editor has a file-type menu, set it to All Files or plain text so it does not append .txt to the name.
- 6. Open the saved file in a web browser to confirm that it renders.
If you prefer the command line, you can write the clipboard contents straight to a file. On macOS, use the first command in Terminal. On Windows, use the second command in PowerShell.
pbpaste > logo.svg
Get-Clipboard | Set-Content logo.svg -Encoding utf8
Fixing code that will not open or renders wrong
Code copied from a web page often depends on that page to display correctly. Once the code is in its own file, check for these common problems.
- Missing namespace: SVG embedded inside HTML can display without an xmlns attribute, but a standalone .svg file needs one. The opening svg tag must declare the official SVG namespace. Any SVG exported from a vector editor includes this declaration, so you can copy it from such a file.
- Hidden .txt extension: if the file opens as text, the system may have saved it as logo.svg.txt. Turn on file-extension display and rename the file.
- Smart quotes or rich formatting: word processors can replace straight quotation marks with curly ones, which breaks the markup. Paste the code again in a plain-text editor.
- External styling: if the code uses class names but contains no style element, its colors and strokes were defined in the website's stylesheet. Those rules must be copied into the file or applied directly to the shapes.
- currentColor: this value inherits color from the surrounding page. In a standalone file it usually falls back to black, so replace it with the intended color value.
- External references: a use element pointing to a separate sprite file will show nothing once the file is isolated. The referenced symbol must be copied into the file.
- Data URIs: code that starts with data:image/svg+xml is an encoded string, not raw markup. A URL-encoded string must be decoded first. A base64 string can be decoded with a command such as the one shown below, after removing the prefix that ends in base64 and the comma.
echo 'PASTE_BASE64_STRING_HERE' | base64 --decode > logo.svg
When the markup is malformed, a browser typically shows an XML parsing error instead of the image. The error usually points to the line where the problem starts, which helps you find an unclosed tag or a broken attribute.
Verifying that the file is usable logo artwork
A file that displays in a browser is not necessarily ready for delivery. The .svg extension does not prove that the content is fully vector or editable, so open the file in a vector editor such as Illustrator, Inkscape or Affinity Designer and check the following points.
- Scaling: zoom in closely. Vector paths stay sharp at any magnification, while blurry or pixelated areas indicate embedded raster content.
- Embedded images: search the code for an image element. If one is present, part or all of the logo is a bitmap wrapped in SVG markup, and it will not scale or edit like true vector artwork.
- Text handling: a text element means the lettering depends on the font installed on whatever device opens the file. If that font is missing, a substitute is used and the logo changes. For delivery, convert the lettering to outlines in a vector editor and keep a separate editable master with live text.
- viewBox: confirm that the opening svg tag has a viewBox. Without one, the logo may not scale predictably in layouts or on websites.
- Editability: select individual shapes to confirm they are separate, editable paths with the expected fills and strokes.
- Clean boundaries: check that the artwork is not clipped and does not have unexpected empty space around it. Either problem suggests that the viewBox or canvas size needs adjusting.
Print delivery and usage rights
SVG is primarily a screen and web format. Print workflows often ask for different vector formats, such as PDF or EPS, and may specify a color mode. Requirements vary by printer, and no particular specification was supplied for this guide, so confirm the accepted formats with the print provider. A vector editor can open the verified SVG and export it to the required format.
Saving a logo's code from a website gives you a working file, but it does not give you permission to use the logo. Brand marks are generally protected, so use them only with the owner's authorization or within their published usage guidelines. Ideally, obtain the official master files from the brand owner rather than reconstructing them from website code.