Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Wiki
    • Web Shop
    • Newsletter
    • RSS
  •   Jobs
  •   Videos
  •   Blog
  •   Sustainability
  • Bin2C
    placeholder height 250

    Bin2C—Binary to C Converter

    Bin2C is a command-line utility for Windows which takes a binary (or HTML or text) file as input and converts it to a C-array that can be directly included in target application code.

    1. 1.Using Bin2C
    2. 2.Example, Create C-File From Test.html
      1. 2.1.Content of test.html
      2. 2.2.Content of test.c
      3. 2.3.Content of test.h

    Bin2C does not require additional software to be installed (runs stand-alone). Typical usage applications are data that need to be included in a C-program,
    such as FPGA configuration data, bitmaps in portable format (such as GIF, PNG), web pages that need to be delivered by a built-in web server etc.

    Using Bin2C

    The Bin2C utility is very simple to use. It expects a path to an existing file as an input parameter as well as a path to an output file. The input file will be read as binary input data and output into a C-array in the output file. The C-array can be easily compiled into an application.

    If the utility is started without any file input, it will print its usage information.

    bin2c no input

    Example, Create C-File From Test.html

    The following command-line is used: Bin2C.exe test.html test

    This results in the following files

    • test.html
    • test.c
    • test.h

     

    Content of test.html

    <html>
      <head>
        <title>Testpage</title>
      </head>
      <body>
        <p>This is a test paragraph</p>
        <ol>
          <li>This is a test list entry 0</li>
          <li>This is a test list entry 1</li>
        </ol>
      </body>
    </html>

     

    Content of test.c

    /*********************************************************************
    *               SEGGER MICROCONTROLLER GmbH & Co. KG                 *
    *       Solutions for real time microcontroller applications         *
    **********************************************************************
    *                                                                    *
    *       (c) 2002 - 2015  SEGGER Microcontroller GmbH & Co. KG        *
    *                                                                    *
    *       www.segger.com     Support: support@segger.com               *
    *                                                                    *
    **********************************************************************
     
    ----------------------------------------------------------------------
    File    : test.c
    Purpose : Automatically created from test.html using Bin2C.exe
    --------  END-OF-HEADER  ---------------------------------------------
    */
    
    #include "test.h"
    const unsigned char test_file[198] =
    {
      0x3c,  0x68,  0x74,  0x6d,  0x6c,  0x3e,  0x0d,  0x0a,  0x3c,  0x68,
      0x65,  0x61,  0x64,  0x3e,  0x3c,  0x2f,  0x68,  0x65,  0x61,  0x64,
      0x3e,  0x0d,  0x0a,  0x3c,  0x74,  0x69,  0x74,  0x6c,  0x65,  0x3e,
      0x54,  0x65,  0x73,  0x74,  0x70,  0x61,  0x67,  0x65,  0x3c,  0x2f,
      0x74,  0x69,  0x74,  0x6c,  0x65,  0x3e,  0x0d,  0x0a,  0x3c,  0x62,
      0x6f,  0x64,  0x79,  0x3e,  0x0d,  0x0a,  0x3c,  0x70,  0x3e,  0x54,
      0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,  0x20,  0x74,
      0x65,  0x73,  0x74,  0x20,  0x70,  0x61,  0x72,  0x61,  0x67,  0x72,
      0x61,  0x70,  0x68,  0x3c,  0x2f,  0x70,  0x3e,  0x0d,  0x0a,  0x3c,
      0x6f,  0x6c,  0x3e,  0x0d,  0x0a,  0x20,  0x20,  0x3c,  0x6c,  0x69,
      0x3e,  0x54,  0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,
      0x20,  0x74,  0x65,  0x73,  0x74,  0x20,  0x6c,  0x69,  0x73,  0x74,
      0x20,  0x65,  0x6e,  0x74,  0x72,  0x79,  0x20,  0x30,  0x3c,  0x2f,
      0x6c,  0x69,  0x3e,  0x0d,  0x0a,  0x20,  0x20,  0x3c,  0x6c,  0x69,
      0x3e,  0x54,  0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,
      0x20,  0x74,  0x65,  0x73,  0x74,  0x20,  0x6c,  0x69,  0x73,  0x74,
      0x20,  0x65,  0x6e,  0x74,  0x72,  0x79,  0x20,  0x31,  0x3c,  0x2f,
      0x6c,  0x69,  0x3e,  0x0d,  0x0a,  0x3c,  0x2f,  0x6f,  0x6c,  0x3e,
      0x0d,  0x0a,  0x3c,  0x2f,  0x62,  0x6f,  0x64,  0x79,  0x3e,  0x0d,
      0x0a,  0x3c,  0x2f,  0x68,  0x74,  0x6d,  0x6c,  0x3e, };
    
    /****** End Of File *************************************************/

     

    Content of test.h

    /*********************************************************************
    *               SEGGER MICROCONTROLLER GmbH & Co. KG                 *
    *       Solutions for real time microcontroller applications         *
    **********************************************************************
    *                                                                    *
    *       (c) 2002 - 2015  SEGGER Microcontroller GmbH & Co. KG        *
    *                                                                    *
    *       www.segger.com     Support: support@segger.com               *
    *                                                                    *
    **********************************************************************
    ----------------------------------------------------------------------
    File    : test.h
    Purpose : Automatically created from test.html using Bin2C.exe
    --------  END-OF-HEADER  ---------------------------------------------
    */
    #ifndef __TEST_H__
    #define __TEST_H__
    
    #define TEST_SIZE 198
    
    extern const unsigned char test_file[198];
    
    #endif
    
    //__TEST_H__
    
    /****** End Of File *************************************************/

    About us

    • The Company
    • Partners
    • Job Offers
    • Media
    • Contact us

    Support

    • Technical Support
    • Blog
    • Forum
    • Wiki

    Downloads

    • Application Notes
    • Embedded Studio
    • embOS
    • emCompress
    • emCrypt
    • emFile
    • emLib
    • emLoad
    • emModbus
    • emNet
    • emPower
    • emSecure
    • emSSH
    • emSSL
    • emUSB-Device
    • emUSB-Host
    • emVNC
    • emWin
    • Flasher
    • Free Utilities
    • IoT
    • J-Link / J-Trace
    • Linux Studio
    • SystemView
    • CE / REACH

    Social Media

    Headquarters

    SEGGER Microcontroller GmbH

    Ecolab-Allee 5
    40789 Monheim am Rhein, Germany
    info@segger.com
    Tel.: +49-2173-99312-0
    Fax: +49-2173-99312-28

    Locations

    USA: SEGGER Microcontroller Systems LLC

    Boston area
    101 Suffolk Lane
    Gardner, MA 01440, USA
    us-east@segger.com
    Tel.: +1-978-874-0299
    Fax: +1-978-874-0599

    Silicon Valley
    Milpitas, CA 95035, USA
    us-west@segger.com
    Tel.: +1-408-767-4068

    China: SEGGER Microcontroller China Co., Ltd.

    Room 218, Block A, Dahongqiaoguoji
    No. 133 Xiulian Road
    Minhang District, Shanghai 201199, China
    china@segger.com
    Tel.: +86-133-619-907-60

    ISO 9001 certified

    ISO 9001

    30+ years of experience

    First-class embedded software tools since 1992
    • Imprint
    • Disclaimer
    • Privacy Policy

    © 2023 SEGGER - All rights reserved.